I am trying to use AuthManager to login a user. The code is as
this.authMgr.login({
account: 'hangingsteel',
project: 'well-factory',
groupId: 'hangingsteel-dev-oct-2015',
userName: username,
password: pass
}).then(function(statusObj) {
// if enduser1 belongs to exactly one group
// (or if the login() call is modified to include the group id)
console.log(statusObj);
let sessionObj = this.authMgr.getCurrentUserSessionInfo();
console.log(this.authMgr.getCurrentUserSessionInfo());
// continue here
}.bind(this)).fail(function(statusObj) {
// if enduser1 belongs to multiple groups,
// the login() call fails
// and returns all groups of which the user is a member
for (var i=0; i < statusObj.userGroups.length; i++) {
console.log(statusObj.userGroups[i].name, statusObj.userGroups[i].groupId);
}
return this.setState({ error: true });
});
I got 4 forio.com network request/response, and statusObj is valid
Object = $1
auth: {refresh_token: “eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI5M2FkOTIxNy1jMjIyL…F3yCV30cW9P8ieoX4m6cwrwjvzJBU846ULS7VMKUsaDOrayvw”, access_token: “eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIwZWNmMTU1Ny04NzJjL…y_VyoiEXF-x3yfHrBMp-fLg_EM6_6eaYozy6utM2fZkQKm4Uw”, expires: 43199}
groupSelection: {well-factory: “a5f09ae8-6db8-4c3c-ab43-aa12a96c21cd”}
user: {jti: “0ecf1557-872c-40e4-b170-e6be71d50b6b”, sub: “c992a12b-d17c-4cc1-901c-c33496279526”, scope: [“oauth.approvals”, “openid”], client_id: “login”, cid: “login”, …}
userGroups: [Object] (1)
However, this.authMgr.getCurrentUserSessionInfo(); returns an empty object. And I got access denied error status 401 when accessing the model.
What did I do wrong? Please help.
Jay