Skip to content

docs: clarify -BearerToken/-Token examples accept both "Bearer <token>" and raw token forms - #909

Open
pavankadabala-png wants to merge 11 commits into
d365collaborative:masterfrom
pavankadabala-png:fix/666-bearer-token-examples
Open

docs: clarify -BearerToken/-Token examples accept both "Bearer <token>" and raw token forms#909
pavankadabala-png wants to merge 11 commits into
d365collaborative:masterfrom
pavankadabala-png:fix/666-bearer-token-examples

Conversation

@pavankadabala-png

@pavankadabala-png pavankadabala-png commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Updates the LCS cmdlet comment-based-help examples to reflect how the token parameters actually behave, per the revised scope of #666.

Background: the original issue reported that the Bearer prefix in the -BearerToken/-Token examples caused auth errors. On closer investigation (thanks @FH-Inway), the public LCS cmdlets normalize the token — a StartsWith("Bearer ") guard auto-prepends Bearer when it's missing — so both "Bearer <token>" and "<token>" are valid and produce the same result.

Public cmdlets (Invoke-D365LcsUpload, Get-D365LcsDeploymentStatus, Invoke-D365LcsDeployment): rather than removing the prefix, the examples now show both forms are accepted. Each gets a second .EXAMPLE using the Bearer -prefixed token, and the .PARAMETER BearerToken description notes the prefix is optional and prepended automatically when missing.

Internal functions (Start-LcsUploadV2, Complete-LcsUploadV2, Get-LcsDeploymentStatusV2, Get-LcsEnvironmentHistory, Get-LcsEnvironmentMetadata, Start-LcsDeploymentV2): these have no normalization and always require the prefix, so their examples keep the Bearer <token> form (restored to match the internal API contract). This leaves them identical to master, so they no longer appear in the diff.

Consistency check: all 16 public LCS cmdlets that send a token to the API already carry the StartsWith("Bearer ") guard. The only token-parameter cmdlet without it is Set-D365LcsApiConfig, which just stores the token in config and never calls the API, so it doesn't need normalization.

Only .EXAMPLE / .PARAMETER help text changed — no functional/normalization code was touched.

Closes #666

@FH-Inway

Copy link
Copy Markdown
Member

@pavankadabala-png Not sure if you saw the comment on the issue: #666 (comment)
Let me know if you are interested in working on this changed issue scope.

@pavankadabala-png

Copy link
Copy Markdown
Contributor Author

Thanks @FH-Inway, no problem on the scope change — happy to take it on.

Here's the plan:

  • Public LCS cmdlets (the ones with the StartsWith("Bearer ") normalization): instead of dropping the prefix, I'll show both forms work — one .EXAMPLE with -BearerToken "Bearer Jldjfaf..." and one with -BearerToken "Jldjfaf...", plus a .PARAMETER note that the Bearer prefix is optional and gets prepended automatically when missing.
  • Internal functions (Start-LcsUploadV2, Complete-LcsUploadV2, Get-LcsDeploymentStatusV2, Get-LcsEnvironmentHistory, Get-LcsEnvironmentMetadata, Start-LcsDeploymentV2): no normalization here, so they always need the prefix. I'll put Bearer back in their -Token/-BearerToken examples.
  • On the consistency question: all 16 public LCS cmdlets that send a token to the API already have the StartsWith("Bearer ") guard, so that's consistent. The only token-parameter cmdlet without it is Set-D365LcsApiConfig, which just stores the token and never calls the API, so it doesn't need normalization.

Pushing the updated commits shortly.

…let examples (d365collaborative#666)

Per the d365collaborative#666 scope change: the public cmdlets normalize the token (StartsWith("Bearer ") guard), so both "Bearer <token>" and "<token>" are valid. Added a second .EXAMPLE demonstrating the "Bearer " form and noted in .PARAMETER that the prefix is optional and prepended automatically when missing.
d365collaborative#666)

Per the d365collaborative#666 scope change: unlike the public cmdlets, these internal functions have no StartsWith("Bearer ") normalization and always require the token to include the "Bearer " prefix. Reverts their -Token/-BearerToken examples back to the "Bearer <token>" form.
@pavankadabala-png pavankadabala-png changed the title fix: remove misleading 'Bearer ' prefix from -BearerToken/-Token CBH examples docs: clarify -BearerToken/-Token examples accept both "Bearer <token>" and raw token forms Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix examples with -BearerToken parameter

2 participants