benbaran / adal-angular4

Angular 4/5/6/7 ADAL Wrapper
MIT License
86 stars 104 forks source link

getUser null after login #85

Closed goggenb closed 6 years ago

goggenb commented 6 years ago

I am having troubles with handleWindowCallback. After it is called, getUser still return null.

I have stepped through adal.service in debug and it gets a hash from the url and says it is valid. When it comes to line 98 in adal.service typeof this.context.callback === 'function' returns false and it jumps to removing hash from url.

This is the first time I am using the adal library so I am not sure what is supposed to happen here, but it seems to me login from AD is successful, but the user is not saved correctly in adal.

Here is what my requestInfo looks like: parameters: { id_token: "eyJ0eXAiOiJKV1Q....", session_state: "407c45df....", state: "9daf2194..." }, requestType: "LOGIN", stateMatch: true, stateResponse: "9daf2194....". valid: true

narenmakwana commented 6 years ago

just curious did you decrypt id_token and see the values in that are correct ? does it have userName object ?

goggenb commented 6 years ago

It does not have userName. It has email, name, and unique_name of those containing my name/username

narenmakwana commented 6 years ago

my guess is you need to setup scopes property . is it on prem ADFS or AZURE AD ? if its on prem ADFS this might help

https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/development/enabling-oauth-confidential-clients-with-ad-fs

it has some screen shots . look at point 13

goggenb commented 6 years ago

You are correct that it was a configuration issue. ClientID was set up wrong, and once we got that set correctly, getUser() is no longer null. The decoded token does still not contain a userName though :P This is azure AD by the way.

Thanks for the help guiding me to the solution.