(‘Missing parameters. “username” and “password” are required’): But I have the username and password in my code. Please let me know what am I missing.
I also noticed the sample code here at the link below has Syntax Errors. I think missing ) right before 1st .then and extra } second from the last line.
https://docs.particle.io/reference/javascript/#create-user
I corrected them and run the code below:
particle.createUser({username:'my_email@testemail.com',password:'xxxxxxxiiiivvv' }).then(function(data) {
var loginPromise = particle.login('my_email@testemail.com', 'xxxxxxxiiiivvv');
loginPromise.then(
function(data) {
console.log('Login successful! access_token:', data.access_token);
},
function(err) {
console.log('Login failed:', err);
}
);
});
get the response below (‘Missing parameters. “username” and “password” are required’):
Login failed: { statusCode: 400,
errorDescription: 'HTTP error 400 from /oauth/token - Missing parameters. "username" and "password" are required',
error:
{ [Error: Bad Request]
original: null,
response:
Response {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
res: [Object],
request: [Object],
req: [Object],
links: {},
text: '{\n "error": "invalid_client",\n "error_description": "Missing parameters. \\"username\\" and \\"password\\" are required"\n}',
body: [Object],
files: {},
buffered: true,
headers: [Object],
header: [Object],
statusCode: 400,
status: 400,
statusType: 4,
info: false,
ok: false,
redirect: false,
clientError: true,
serverError: false,
error: [Object],
accepted: false,
noContent: false,
badRequest: true,
unauthorized: false,
notAcceptable: false,
forbidden: false,
notFound: false,
charset: 'utf-8',
type: 'application/json',
setEncoding: [Function: bound ],
redirects: [] },
status: 400 },
body:
{ error: 'invalid_client',
error_description: 'Missing parameters. "username" and "password" are required' } }