Graph API Expiry

Abhay Chandramouli 1,056 Reputation points
2022-07-21T05:46:52.423+00:00

I want to extend the expiry time in graph api token. Is it possible ?

Microsoft Security Microsoft Entra Microsoft Entra External ID
Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

Accepted answer
  1. AmanpreetSingh-MSFT 56,871 Reputation points Moderator
    2022-07-21T10:27:31.527+00:00

    Hi @Abhay Chandramouli • Thank you for reaching out.

    Yes, you can extend the expiry time of the Access Token acquired for Graph API. For this purpose, you need to perform the below steps in your B2C tenant:

    1. Navigate to Azure AD > Enterprise Applications > Set Application Type to All Application > Search for GraphAggregatorService and copy the object ID.
    2. Run the below PowerShell script as Global Administrator to set the Access Token Lifetime to 8 hours for example. (Maximum can be 24 hours) Connect-AzureAD
      $policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"08:00:00"}}') -DisplayName "GraphAPITokenLifetime" -IsOrganizationDefault $false -Type "TokenLifetimePolicy"
      Get-AzureADPolicy -Id $policy.Id
      $sp = Get-AzureADServicePrincipal -ObjectId Object_ID_Copied_in_Step_1
      Add-AzureADServicePrincipalPolicy -Id $sp.ObjectId -RefObjectId $policy.Id

    Once done, try to acquire a new Access Token for Graph API and notice the expiry time set to 8 hours (28799 seconds).

    222949-image.png

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


1 additional answer

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-07-21T07:19:08.537+00:00

    It's possible, to an extent. Check the official documentation for more details: https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-tokens?pivots=b2c-user-flow


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.