Acquiring new access token using refresh token adal js

瘦欲@ 提交于 2020-01-14 14:27:12

问题


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.


回答1:


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.




回答2:


If you are using angular wrapper, then adal will take care of renewing tokens automatically as Karthik mentioned above.

If you are not using angular wrapper, then you can call acquireToken method to renew token. This might help: https://github.com/Azure-Samples/active-directory-javascript-singlepageapp-dotnet-webapi



来源:https://stackoverflow.com/questions/37535366/acquiring-new-access-token-using-refresh-token-adal-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!