Skip to content

Commit 635901f

Browse files
The script needs more permission scope
When I ran the script, it fails with "Insufficient privileges to complete the operation." error. The script only has "Policy.ReadWrite.ApplicationConfiguration". "New-MgPolicyTokenLifetimePolicy" sends POST to https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies. "Get-MgPolicyTokenLifetimePolicy" sends GET to the same endpoint https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies "New-MgApplicationTokenLifetimePolicyByRef" sends POST to https://graph.microsoft.com/v1.0/applications/{AppID}/tokenLifetimePolicies/$ref This doc shows "Policy.ReadWrite.ApplicationConfiguration" only POST but doesn't include GET. https://learn.microsoft.com/en-us/graph/permissions-reference#example-usage-32 This doc guides that these permissions are needed to run token lifetime policy. "Policy.ReadWrite.ApplicationConfiguration","Policy.Read.All","Application.ReadWrite.All" https://learn.microsoft.com/en-us/graph/api/application-post-tokenlifetimepolicies?view=graph-rest-1.0&tabs=http When I edited the scope part (line 32) as below, I could run the whole script without an error. Connect-MgGraph -Scopes "Policy.ReadWrite.ApplicationConfiguration","Policy.Read.All","Application.ReadWrite.All" I also confirmed that after running the script the token lifetime was updated successfully from the token.
1 parent 50c68f9 commit 635901f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

articles/active-directory/develop/configure-token-lifetimes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ To get started, download the latest [Microsoft Graph PowerShell SDK](/powershell
2929
In the following steps, you'll create a policy that requires users to authenticate less frequently in your web app. This policy sets the lifetime of the access/ID tokens for your web app.
3030

3131
```powershell
32-
Connect-MgGraph -Scopes "Policy.ReadWrite.ApplicationConfiguration"
32+
Connect-MgGraph -Scopes "Policy.ReadWrite.ApplicationConfiguration","Policy.Read.All","Application.ReadWrite.All"
3333
3434
# Create a token lifetime policy
3535
$params = @{
@@ -76,4 +76,4 @@ GET https://graph.microsoft.com/v1.0/policies/tokenLifetimePolicies/4d2f137b-e8a
7676
```
7777

7878
## Next steps
79-
Learn about [authentication session management capabilities](../conditional-access/howto-conditional-access-session-lifetime.md) in Azure AD Conditional Access.
79+
Learn about [authentication session management capabilities](../conditional-access/howto-conditional-access-session-lifetime.md) in Azure AD Conditional Access.

0 commit comments

Comments
 (0)