Access Token expiry time and refresh token

Ankur Shah 66 Reputation points
2022-04-14T06:47:58.26+00:00

I am using client credential flow, and getting token via this:
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(client_id)
.clientSecret(secret)
.tenantId(tenant)
.build();

authProvider = new TokenCredentialAuthProvider(clientSecretCredential);

// Build a Graph client
graphClient = GraphServiceClient.builder()
    .authenticationProvider(authProvider)
    .buildClient();

I wanted to know what is the expiry time of the token and how I would get refresh token or generate new token when it expires?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,874 questions
0 comments No comments
{count} votes

Accepted answer
  1. Zehui Yao_MSFT 5,831 Reputation points
    2022-04-14T08:47:55.79+00:00

    Hello @Ankur Shah , the expiry time of the token is about one hour, as the documentation mentioned.
    193024-image.png
    And client credential flow will not issue refresh tokens, the client can make the same call again to obtain a new access token.
    by the way, you can extend the lifetime of the access token by configuring the access token lifetime policy, but the maximum lifetime of the token still cannot exceed 24 hours.

    So if you want to get refresh token the only way is to use auth code flow or ROPC flow.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful