Help requested for using refresh token
Closed this issue · 1 comments
Hi,
Thanks for this great example. The Demo works and I can see the emails for a myemail@outlook.com account
I'm trying to use the sample to renew the access token using a refresh token, but the authResult does not contain a refresh token. I see refresh tokens in the authContext, but I don't know how to use those refresh tokens.
Should you use the refresh token in combination with AcquireTokenSilentAsync() or do you have to do this in another way.
Hope you can give me some example of how to do this.
So the way the ADAL library wants you to do this is to implement a TokenCache
that will store the cached refresh tokens for you. TokenCache
is an interface that you would implement, then pass an instance of your class to the AuthenticationContext
constructor. By default it uses an in-memory cache, so you can try it out without implementing it if you want to try it out.
Yes, the AcquireTokenSilentAsync
method uses the cache. So the idea here is that you would call this function every single time you want to get the token for use. The function checks for expiration and just returns out of the cache if not expired, and uses the refresh token for you if it is expired.