Skip to content
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

Include TokenRequestOptions with authentication required error #22261

Closed
chlowell opened this issue Jan 17, 2024 · 0 comments · Fixed by #22317
Closed

Include TokenRequestOptions with authentication required error #22261

chlowell opened this issue Jan 17, 2024 · 0 comments · Fixed by #22317
Assignees
Labels
Azure.Identity feature-request This issue requires a new behavior in the product in order be resolved.
Milestone

Comments

@chlowell
Copy link
Contributor

When GetToken returns an error because user interaction is required and the credential is configured not to prompt for it automatically, that error should include the TokenRequestOptions passed to GetToken. This would make Authenticate much easier to use by providing the application a simple way to request the necessary token. The calling pattern would look like this:

cred, err := azidentity.NewInteractiveBrowserCredential(&azidentity.InteractiveBrowserCredentialOptions{
    DisableAutomaticAuthentication: true,
    TokenCachePersistenceOptions: &azidentity.TokenCachePersistenceOptions{},
})
client, err := NewServiceClient(cred)
err = client.Frobulate(context.TODO())
var authReqErr *azidentity.AuthenticationRequiredError
if errors.As(err, &authReqErr) {
    // User interaction required, app calls Authenticate when that's convenient.
    // Developer doesn't need to consider parameters because the given
    // TokenRequestOptions describes exactly the token the client requested.
    cred.Authenticate(context.TODO(), &authReqErr.TokenRequestOptions)
}
// TODO: retry Frobulate
@chlowell chlowell added Azure.Identity feature-request This issue requires a new behavior in the product in order be resolved. labels Jan 17, 2024
@chlowell chlowell added this to the 2024-04 milestone Jan 17, 2024
@chlowell chlowell self-assigned this Jan 17, 2024
@RickWinter RickWinter modified the milestones: 2024-04, 2024-03 Mar 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity feature-request This issue requires a new behavior in the product in order be resolved.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants