Honor access token type in bearer auth policy#49542
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
⚠️ Not ready to approve
The new null/empty token-type fallback branch is not currently covered by tests, leaving the defaulting behavior unverified.
Pull request overview
Updates BearerTokenAuthenticationPolicy in azure-core to honor AccessToken.getTokenType() when forming the Authorization header, enabling non-Bearer schemes (e.g., Pop) while retaining Bearer as the default behavior.
Changes:
- Use
AccessToken(includingtokenType) when setting theAuthorizationheader in both async and sync flows. - Add new unit tests asserting that a non-default token type (e.g.,
Pop) is used in theAuthorizationheader.
File summaries
| File | Description |
|---|---|
| sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java | Switch header construction to incorporate AccessToken.getTokenType() with a fallback to Bearer. |
| sdk/core/azure-core/src/test/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicyTests.java | Add async and sync tests validating that tokenType is reflected in the Authorization header. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
| } | ||
| assertEquals("Pop token", authorizationHeader.get()); | ||
| } | ||
|
|
|
the mTLS token binding support is not available currently in downstream SDKs. |
Updates BearerTokenAuthenticationPolicy to use AccessToken.getTokenType() when setting the Authorization header. This is a Core prerequisite for PoP/MSI token binding flows while preserving Bearer as the default.\n\nValidation:\n- mvn -pl sdk/core/azure-core -Dtest=BearerTokenAuthenticationPolicyTests test -DskipCheckStyle=true -DskipRevapi=true -Dgpg.skip=true -q