Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiration time of current access token #207

Open
aregaz opened this issue Oct 29, 2018 · 0 comments
Open

Expiration time of current access token #207

aregaz opened this issue Oct 29, 2018 · 0 comments

Comments

@aregaz
Copy link

aregaz commented Oct 29, 2018

I have an issue with requests for which execution takes more time then default expiration time (1 hour). I'm trying to check access token expiration time before sending next request, but it seems that TokenProvider.GetAccessToken() just generates new access token on each execution.

You can get an idea of my logic from the following:

  • was:
CloudMediaContext _mediaContext = ...
var job = _mediaContext.Jobs.CreateWithSingleTask(...);
await job.SubmitAsync(); // takes more then 1 hour

return _mediaContext.Assets.Where(...).First(); // throws exception due to invalid token
  • what I'm trying to do:
CloudMediaContext _mediaContext = ...
var job = _mediaContext.Jobs.CreateWithSingleTask(...);
await job.SubmitAsync(); // takes more then 1 hour

DateTimeOffset tokenExpirationDate = _mediaContext.TokenProvider.GetAccessToken().Item2;
if (tokenExpirationDate < DateTimeOffset.UtcNow) // always false since previous line returns new token and expiration time
{
    // get new context (generates new token)
    _mediaContext = ...
}

return _mediaContext.Assets.Where(...).First(); // fails since token was not re-generated

My solution never refresh the context since if-statement condition is never occurs to be true.
Is there any way to get expiration time of current access token generated by ITokenProvider?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant