0

we're working on some Azure-related script using ADAL for authentication. I'm working on the code for refreshing the access token, and would like to test this without having to wait for 60 minutes until the access token expires. Anyone know if there's a way to reduce the token lifetime to ease testing scenarios?

Trondh
  • 3,221
  • 1
  • 25
  • 34

1 Answers1

1

If you are using ADAL the refresh logic is already provided by the library automatically. Whenever you call AcquireToken* ADAL will either return the cached token if present and still within validity range or use the refresh token to get you a new one. For that reason, there are no knobs for getting a new access token before its validity expires. You can use experience modifiers (like PromptBehavior) for ignoring the cache, or you can surgically delete the cache entry for the token you are worksite its, but both approaches will result in deleting the refresh token too and in a prompt to the user.

vibronet
  • 7,364
  • 2
  • 19
  • 21
  • Thanks vibronet. This is part of a PowerShell module for Azure I'm building, and I'd rather not have to call acquiretoken on every call the user makes thru the model, which I guess is a bit non-standard usage for adal. We currently track the accesstoken and expiry in variables and refresh as needed (which works fine), but it's hard to test it when having to wait 60 minutes. – Trondh Dec 25 '15 at 16:21
  • Is there any specific reason for which you don't want to call acquiretoken? I highly recommend calling acquiretoken every time. There are many things ADAL does behind the scenes every time you make that call, which you might not be able to reproduce in your own code. Furthermore, we will soon stop returning refresh tokens to your code and use it transparently - hence you will simply not be able to use it – vibronet Dec 25 '15 at 16:28