Forum Discussion
ADAL JS get token fails from Modern SharePoint Page / SPFX?
I am having a problem while getting authContext.getCachedUser() , it always returns null though user already authenticated in Sharepoint.
I have custom JavaScript that uses ADAL JS running in SharePoint Online site page. The JavaScript makes a call to Web API end point using the access token (implicit grant) from AAD.
The problem I have is in getting cached user details in SPO – the getCachedUser method of ADAL always returns null hence forcing the user to login when the script runs on the page ( remember the user has already logged into to the site )
var user = authContext.getCachedUser();
if (!user) {
authContext.login();
}
Is there a way to get User ID storage token in SharePoint Online using ADAL? Let me phrase this way – In SharePoint Online, how do we get logged in user using ADAL so that user doesn’t have to login again when the script runs? The cache location I’m using is LocalStorage.
Could you please share your working config information.
Thanks,
Rajamani
Thanks in advance