AuthManager getCurrentUserSessionInfo is empty

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

What’s an url I can go to to look at this? Also, what’s the userid you’re trying to login with?

Hi Naren,

It’s on my local machine, I don’t have a link. I tried to create a jsfiddle forio auth

The jsfiddle is not working neither. Somehow it is not hitting forio.com for auth request. The code is about the same as in my local machine. I do hit the forio.com in my local machine though.

user name is jaytest, account ‘hangingsteel’

I got for network activities from the server for the code, the last response is

[{“members”:[{“expirationDate”:“2017-04-15T00:00:00.000Z”,“userId”:“c992a12b-d17c-4cc1-901c-c33496279526”,“role”:“standard”,“userName”:“jaytest”,“account”:“hangingsteel”,“lastName”:“Jay Test”,“active”:true,“runLimit”:100}],“account”:“hangingsteel”,“project”:“well-factory”,“type”:“local”,“groupId”:“a5f09ae8-6db8-4c3c-ab43-aa12a96c21cd”,“name”:“hangingsteel-dev-oct-2015”}]

However, the getCurrentUserSessionInfo is always returning empty object.

Hi Jay,

The jsfiddle won’t work because of cross-domain issues. For something like logging in it’s hard to debug without looking at a live page. If you could either attach a standalone html file here which has this issue, or just upload your code to any of your projects we can look further.

-Naren