microsoftgraph / microsoftgraph/msgraph-sdk-powershell

Remove-MgServicePrincipalTokenLifetimePolicyByRef is not using the correct underlying HTTP Graph endpoint

Open
#3,728 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:waiting-for-triage type:bug
Dominant language
C#
Stars
898
Forks
230
Avg merge
2d 5h
Merged PRs (30d)
31

Description

Describe the bug

I am using Microsoft.Graph version 2.39.0 on PowerShell 7.
The commandlet Remove-MgServicePrincipalTokenLifetimePolicyByRef is not sending out the correct MS Graph endpoint leading to error

PS C:\Users\bachoang> Remove-MgServicePrincipalTokenLifetimePolicyByRef -ServicePrincipalId xyz -Id abc -Debug
DEBUG: [CmdletBeginProcessing]: - Remove-MgServicePrincipalTokenLifetimePolicyByRef begin processing with parameterSet 'Delete'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [Application.Read.All, Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All, AuditLog.Read.All, DelegatedPermissionGrant.ReadWrite.All, Directory.AccessAsUser.All, Directory.Read.All, Directory.ReadWrite.All, GroupMember.Read.All, openid, Policy.Read.All, Policy.ReadWrite.ApplicationConfiguration, profile, User.Read, UserAuthenticationMethod.ReadWrite.All, email].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
DELETE

Absolute Uri:
https://graph.microsoft.com/v1.0/servicePrincipals/xyz/tokenLifetimePolicies/$ref?@id=abc

Headers:
FeatureFlag : 00000003
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.26200; en-US),PowerShell/7.6.5
SdkVersion : graph-powershell/2.38.0
client-request-id : 2671f48e-a8bf-4694-80a2-b3f3997eb73f
Accept-Encoding : gzip,deflate

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Date : Tue, 18 Aug 2026 22:53:04 GMT
Transfer-Encoding : chunked
Connection : keep-alive
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 0981e110-77aa-4c52-8fba-8ad957a58dd2
client-request-id : 2671f48e-a8bf-4694-80a2-b3f3997eb73f
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"005","RoleInstance":"SN4PEPF00000013"}}

The MS Graph URL the commandlet https://graph.microsoft.com/v1.0/servicePrincipals/xyz/tokenLifetimePolicies/$ref?@id=abc sends out is wrong.

The correct MS Graph URL is https://graph.microsoft.com/v1.0/servicePrincipals/xyz/tokenLifetimePolicies/abc/$ref per https://learn.microsoft.com/en-us/entra/identity-platform/configure-token-lifetimes?source=recommendations#create-a-policy-and-assign-it-to-a-service-principal (step 4)

Expected behavior

It should make this correct request:
DELETE https://graph.microsoft.com/v1.0/servicePrincipals/xyz/tokenLifetimePolicies/abc/$re

How to reproduce

see above

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Remove-MgServicePrincipalTokenLifetimePolicyByRef cmdlet entry point and compare its generated DELETE URI with the Microsoft Graph token lifetime policy documentation linked in the issue. Verify that the policy ID is placed in the path before /$ref, then run the relevant cmdlet or request-generation tests if available; done means the command sends the documented endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.