Skip to content

Connection initializes Client with AuthProvider instead AuthString #194

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

magodo
Copy link

@magodo magodo commented Jul 11, 2025

This change is to allow AAD based auth token to refresh when exipred. Previously, if the token encoded in the auth string is expired, the client will always fail.

With this change, the Client is initialized with the AuthProvider, which is built on top of azidentity and MSAL-Go. Everytime the client is gonna make a request, the token will be retrieved from the underlying MSAL-Go library, either from its cache (if not expired) or a fresh new one retrieved via API. This means if the token got expired, a new token will be retireved and used by the client.

However, there is one edge case: Since there is no "token expiration buffer" in the MSAL-Go right now, if the token returned from cache expires right after returning, the client will then use this invalid token for an API call, hence fail. There is no "retry" mechanism in the current client implementation to mitigate this.

I reckon this is a slight breaking change (as the exposed field AuthorizationString of Connection got changed), whilst besides this one, the other API are unchanged.

Relating to: microsoft/terraform-provider-azuredevops#1402

This change is to allow AAD based auth token to refresh when exipred. Previously, if the token encoded in the auth string is expired, the client will always fail.

With this change, the Client is initialized with the `AuthProvider`, which is built on top of `azidentity` and MSAL-Go. Everytime the client is gonna make a request, the token will be retrieved from the underlying MSAL-Go library, either from its cache (if not expired) or a fresh new one retrieved via API. This means if the token got expired, a new token will be retireved and used by the client.

However, there is one edge case: Since there is no "token expiration buffer" in the MSAL-Go right now, if the token returned from cache expires right after returning, the client will then use this invalid token for an API call, hence fail. There is no "retry" mechanism in the current client implementation to mitigate this.
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.

1 participant