Skip to content

400 bad request on invalid login #3

Open
danieleli opened this Issue Aug 27, 2012 · 1 comment

2 participants

@danieleli

type a random username and password and hit login returns 400 from clean clone of repo.

but if you open the url directly you get a nice error code.

for example this url. https://api.usergrid.com/Apigee/messageeapp/token?username=fdfsdf&password=fdfsd&grant_type=password&_=1346027651855

returns this:

{
"error": "invalid_grant",
"error_description": "invalid username or password"
}

Simple fix is on line 1358 of sdk check response.error === undefined or something like that. code below.

function logInAppUser (username, password, successCallback, failureCallback) {
var self = this;
var data = {"username": username, "password": password, "grant_type": "password"};
this.runAppQuery(new Usergrid.Query('GET', 'token', null, data,
function (response) {
!!!!!! check response.error here !!!!!!
var user = new Usergrid.Entity('users');
user.set('username', response.user.username);
user.set('name', response.user.name);
user.set('email', response.user.email);
user.set('uuid', response.user.uuid);
self.setLoggedInUser(user);
self.setToken(response.access_token);
if (successCallback && typeof(successCallback) == "function") {
successCallback(response);
}
},
function (response) {
if (failureCallback && typeof(failureCallback) == "function") {
failureCallback(response);
}
}
));
}

@rodsimpson
Apigee member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.