Comments (13)
Thanks for the bug report! I'll see about making this conditional, and if not, removing it altogether.
from particle-api-js.
Thx bryce.
from particle-api-js.
I'm getting this as well in Chromium with particle.login():
XMLHttpRequest cannot load https://api.particle.io/oath/token. Request header field User-Agent is not allowed by Access-Control-Allow-Headers.
Going to try removing the line that add the User Agent and give it a try.
from particle-api-js.
I just released 5.2.3
which fixes this issue.
from particle-api-js.
Hello @brycekahle
I might be out of line here, i just downloaded version "particle-api-js": "^5.2.6"
{
"name": "photon",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"meteor-node-stubs": "~0.2.0",
"particle-api-js": "^5.2.6"
}
}
made an easy login request
with this code
import { Template } from 'meteor/templating';
import { EventDB } from '../api/eventDB.js';
import { ReactiveDict } from 'meteor/reactive-dict';
import './body.html';
var Particle = require('particle-api-js');
var particle = new Particle();
var access_token = "";
//get access token
particle.login({username: 'email', password: 'password'})
.then(
function(data){
access_token = data.body.access_token;
},
function(err) {
console.log('API call completed on promise fail: ', err);
}
);
var pumpStuff = function(message){
var fnPr = particle.callFunction({
deviceId: 'jackdaniels',
name: 'leanMachine',
argument: message,
auth: access_token
});
fnPr.then(
function(data) {u
console.log('Function called succesfully:', data);
}, function(err) {
console.log('An error occurred:', err);
}
);
};
exports.pumpStuff = pumpStuff;
And i get error in chrome console log
XMLHttpRequest cannot load https://api.particle.io/oauth/token. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
I have been asking on the forum about it but yet not received any answer but other people have reached out to me saying they have this issue as well and it was caused from an update but they cant say which one.
Could this update have anything to do with it?
BR
Dimi
from particle-api-js.
@brycekahle
I am not sure my comment above is valid. It might be so that the login needs to be called from the server part of meteor and not the client. i have not been able to varify thou. Sorry to bother you without testing enough.
/Dimi
from particle-api-js.
@Dimicus I think your bug is valid. I see that superagent
is setting withCredentials to true for browser requests. If the server does not respond with Access-Control-Allow-Credentials: true
and a non *
value for Access-Control-Allow-Origin
, the browser will reject the request.
from particle-api-js.
On further examination, it only sets that if withCredentials()
is called, which we do not.
from particle-api-js.
@brycekahle
Intresting, how come i get the issue when the only thing i do is calling the login function from particle? Will do some more test when i get some time.
Where Can i see IF the package i downloaded with npm install particle-api-Js contains this issue? Please note that other people have claimed the same i.e https://community.particle.io/t/particle-api-js-user-agent-and-cache-control-errors/20664
And some others.
So IT might be some issues
Anyway.
Br
Dimi
from particle-api-js.
@Dimicus the errors in that thread are different and were fixed by the code that solved this issue. What you are experiencing is something different and I have a suspicion that it is meteor related.
from particle-api-js.
I guess you are right.
Bryce. thank you very much and have a great day.
If i find anything related to this i will let you know :)
/Dimi
from particle-api-js.
If you can provide a small example meteor application that demonstrates the error, I can help dig in.
from particle-api-js.
Im pretty sure its meteor now.
Everything works great when i use the code in the server enviroment but if i use the same in client i get the issue.
If you want to test you can use the login example below and use it on main.js in client folder on your meteor project ( meteor 1.3 )
var Particle = require('particle-api-js');
var particle = new Particle();
particle.login({username: '[email protected]', password: 'pass'}).then(
function(data){
console.log('API call completed on promise resolve: ', data.body.access_token);
},
function(err) {
console.log('API call completed on promise fail: ', err);
}
);
Think due to 1.3 that you also need to do meteor install npm, happens alot there now so hard to follow :)
But from my point of view this is all meteor issues, or rather that you need to use credential code in the server and not client, is security :) So its more a feature that you can use it on client side.
BR
Dimi
from particle-api-js.
Related Issues (20)
- Uncaught Error: only one instance of babel-polyfill is allowed HOT 1
- Create Typescript compatible version of API HOT 1
- downloadFirmwareBinary and downloadProductFirmware don't check this.prefix HOT 1
- downloadFirmwareBinary and downloadProductFirmware need tests
- listProductFirmware returns "response" instead of parsed response HOT 1
- uploadProductFirmware only tests with Buffer, and doesn't test with filename HOT 1
- Particle.CallFunction Not Working HOT 3
- loginAsClientOwner only uses default token duration
- particle-api-js ^9.1.0 not working with Svelte ^3.37.0
- 429 error is not properly converted to an object
- Unsupported engine warning, even when node + npm versions meet requirement HOT 1
- EBADENGINE Error because of wrong Version of rpm?
- addDeviceToProduct doesn't appear to reject on error? HOT 1
- Possible issue with activateSIM with products
- Version 7.1.0 not published to npm HOT 2
- How to detect by code the moment of WIFi deconnection?
- Update coveralls when new version is released
- Add tests for EventStream
- Drop Support for Node v4 HOT 1
- `EventStream` doesn't handle dropped connections HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from particle-api-js.