msal-angular icon indicating copy to clipboard operation
msal-angular copied to clipboard

MsalService getUser() method returns undefined

Open nmagesh84 opened this issue 7 years ago • 2 comments

Hi,

The getUser() method returns promise, when accessed to get the user details, it is always undefined.

I'm connecting to Azure B2C tenant, to authenticate.

this.service.getUser().then(userInfo => console.log(userInfo));

I get the token and authenticated bool value correctly. this.service.getToken().then(token => console.log('token: ' + token)); this.service.authenticated.then(auth => console.log('auth: ' + auth));

Regards, Magesh

nmagesh84 avatar Apr 30 '18 11:04 nmagesh84

It looks like it's because local user variable is never set. Looks like somewhere this.user = this.app.getUser() needs to be called.

geerzo avatar May 07 '18 18:05 geerzo

Getting this exact same issue as nmangesh84, not able to get the user info but

this.service.getToken().then(token => console.log('token: ' + token)); this.service.authenticated.then(auth => console.log('auth: ' + auth));

both the above calls return the right data.

hrishikeshpotdar91 avatar May 11 '18 19:05 hrishikeshpotdar91