Skip to content

Add GetTokenOptions #2629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025
Merged

Add GetTokenOptions #2629

merged 2 commits into from
May 29, 2025

Conversation

chlowell
Copy link
Member

Closes #2566

@chlowell chlowell self-assigned this May 22, 2025
@chlowell chlowell added the Azure.Identity The azure_identity crate label May 22, 2025
@github-actions github-actions bot added Azure.Core The azure_core crate Cosmos The azure_cosmos crate labels May 22, 2025
Copy link

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure_core
azure_identity

@chlowell chlowell marked this pull request as ready for review May 22, 2025 22:18
@Copilot Copilot AI review requested due to automatic review settings May 22, 2025 22:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the TokenCredential API to accept an optional GetTokenOptions parameter and updates all existing credentials, cache logic, and examples to propagate it (using None by default). It also refactors the token cache to pass options through to the fetch callback.

  • Extend TokenCredential::get_token to accept Option<GetTokenOptions> and add the GetTokenOptions type.
  • Update every credential implementation (and calling sites) to accept and forward the new options parameter.
  • Refactor TokenCache to accept and pass options to the provided callback function.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

File Description
sdk/core/azure_core/src/credentials.rs Added GetTokenOptions and updated trait signature
sdk/identity/azure_identity/src/credentials/cache.rs Refactored cache to accept options and callback
sdk/identity/azure_identity/src/credentials/imds_managed_identity_credentials.rs Updated get_token signature and calls
Comments suppressed due to low confidence (1)

sdk/identity/azure_identity/src/credentials/cache.rs:30

  • [nitpick] No tests currently pass a non-None GetTokenOptions through the cache. Consider adding a test case that supplies a real GetTokenOptions to ensure it is correctly propagated to the callback.
pub(crate) async fn get_token<'a, C, F>(

Copy link
Member

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosmos changes look fine!

@chlowell chlowell requested a review from heaths May 29, 2025 16:49
@chlowell chlowell merged commit ee975d0 into Azure:main May 29, 2025
18 checks passed
@chlowell chlowell deleted the gto branch May 29, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core The azure_core crate Azure.Identity The azure_identity crate Cosmos The azure_cosmos crate
Projects
Development

Successfully merging this pull request may close these issues.

Add options type for TokenCredential::get_token
3 participants