Acquiring new access token using refresh token adal js

Ramppy Dumppy picture Ramppy Dumppy · May 31, 2016 · Viewed 13.4k times · Source

I am working with an application that authenticate in azure ad. I use adal.js to acquire access token. But the access token is only valid for 1 hour. So how can I acquire new token behind the scene using my refresh token in Adal js?

Appreciate if you can provide sample code.

Answer

Karthik picture Karthik · Jun 13, 2016

As long as the user have an active session with Azure AD, ADAL JS does it automatically for you. ADAL JS examines the projected expiration of the existing token (in the cache) and if the token is about to expire, it uses an invisible iFrame to send a new token (renewal) request to Azure AD.

This is discussed in detail here (with sample code) by Vittorio and the mechanics of silent renewal is discussed here.