ADAL JS get token fails from Modern SharePoint Page / SPFX?

Highlighted
Valued Contributor

Is it possible / (impossible?) to use ADAL Javascript on a SharePoint modern page (SPFX)?

 

I am playing with some Graph API calls from SharePoint, and getting the tokens via ADAL JS seem to work perfectly fine on classic SP pages, but fail everytime on Modern.

 

The error I get is "Token renewal operation failed due to timeout".

 

As long as I go get a token on a classic page, and then return the modern page it works, but if the token has to be renewed, it is unable to do so without first going to modern page.

2 Replies
Highlighted

Were you able to get this to work? Im also in a similar situation now and unable to get a token on modern page

Highlighted

@Brent Ellis 

 

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