Skip to content
This repository was archived by the owner on Jan 23, 2020. It is now read-only.
This repository was archived by the owner on Jan 23, 2020. It is now read-only.

Updating Graph token #29

@programmersommer

Description

@programmersommer

Hi!
It's not really an issue, it's more question.
When Graph token acquired it has a life time 1 hour. Code that could get this code is:

private async Task OnAuthorizationCodeReceivedAsync(AuthorizationCodeReceivedContext context) { string userId = (context.Principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier"))?.Value; var authContext = new AuthenticationContext(context.Options.Authority, new NaiveSessionCache(userId, context.HttpContext.Session)); var credential = new ClientCredential(context.Options.ClientId, context.Options.ClientSecret); var authResult = await authContext.AcquireTokenByAuthorizationCodeAsync(context.TokenEndpointRequest.Code, new Uri(context.TokenEndpointRequest.RedirectUri, UriKind.RelativeOrAbsolute), credential, context.Options.Resource); context.HandleCodeRedemption(authResult.AccessToken, context.ProtocolMessage.IdToken); }

As I see this code could be called only if logout and login again. That is not comfortable. Is there some way to change token live time or update it?
I see only way to get new token somehow with code like this:

AuthenticationContext authContext = new AuthenticationContext(LoginUrl + tenantId, false); ClientCredential credential = new ClientCredential(clientId, clientSecret); AuthenticationResult assertionCredential = await authContext.AcquireTokenAsync(GraphUrl, credential);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions