AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 372 forks source link

ADAL SPFx getCachedUser is always null #751

Closed 2P2-Anthony closed 6 years ago

2P2-Anthony commented 6 years ago

We have an SPFx web part working pretty well, but even if the user is already logged into Office 365 when they hit the page containing the SPFx web part - the getCachedUser object is always null. This forces a redirect for login, which auto-redirects back to our application page immediately.

Our original PoC with straight JavaScript never did this, but the SPFx web part always redirects on first hit.

Has anyone seen and fixed this behaviour? What should we be looking for in our Authentication wrapper?

https://stackoverflow.com/questions/50146519/adal-spfx-getcacheduser-is-always-null

mirahManlapig commented 6 years ago

I'm having the same problem. So i put the authentication in an Iframe having the code below and when i first login or delete localstorage then try to access my app, login, the iframe does not get the token. Can somebody help me?

image

rohitnarula7176 commented 6 years ago

@mirahManlapig You should first call login and then call acquireToken. The library expects a signed in user first before you can call acquireToken for any resource. This is by design.

rohitnarula7176 commented 6 years ago

@mirahManlapig Closing this issue due to lack of response. Please reopen if it is not resolved for you.