The Microsoft access token lifetime policy is applicable on global tenant or organization. The current maximum Access Token lifetime is 24 hours.

Create policy:

Step1: Open Windows PowerShell as Administrator

Step1: Open Windows PowerShell as Administrator
 

Step2: Install Microsoft Graph (if not already installed)

Install-Module Microsoft.Graph -Scope Currentuser

Install Microsoft Graph (if not already installed)


 

Step3: Connect to Microsoft Graph with required scopes (User must have Global Administrator)

Connect-MgGraph -Scopes  "Policy.ReadWrite.ApplicationConfiguration",
"Policy.Read.All","Application.ReadWrite.All"

Step4: Define a token lifetime policy with expire time is 4 hours and it will applied over the organization.

$params = @{

 Definition = @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"4:00:00"}}')

 DisplayName = "WebPolicyScenario"

 IsOrganizationDefault = $true }


 

If error:

then remove current policy then create new policy..remove policy steps

Step5: Create policy

$tokenLifetimePolicy = New-MgPolicyTokenLifetimePolicy -BodyParameter $params

Step6: Store policy Id

$tokenLifetimePolicyId = $tokenLifetimePolicy.Id


 

Step7: Display the policy

Get-MgPolicyTokenLifetimePolicy -TokenLifetimePolicyId $tokenLifetimePolicyId

Now this policy will apply globally for all apps in your tenant unless an app has its own individual token lifetime policy assigned.

Step8: Verify the default global policy applied

Get-MgPolicyTokenLifetimePolicy | where-object { $_.IsOrganizationDefault -eq $true }


 

Remove policy:

Step1: List all token Lifetime policies

Get-MgPolicyTokenLifetimePolicy | Select-Object Id, DisplayName, IsOrganizationDefault

Step2: Remove policy

Remove-MgPolicyTokenLifetimePolicy -TokenLifetimePolicyId de6c7202-9a4c-4c02-81df-b8b5ad876c6e