-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
StaticTokenCredential #22955
StaticTokenCredential #22955
Conversation
What about a static method? We did a similar thing with |
Instead of a ctor? |
Instead of an additional class. TokenCredential.Create(string token) would return a |
Interesting idea - but I'm not sure that I like having a generic TokenCredential that can't be identified specifically as a static token credential. |
Why not? |
I do like this from a design perspective, but honestly I'm not sold on adding the class or the static method. I think either lead users down a bad path because while simply using a static token seems like the path of least resistance, it will only work for a short period of time and the user needs to manage it's lifetime and scope properly which is not trivial. This is why we have be reluctant to add this class, and I think that a static method would exacerbate this problem as users could look at |
sdk/identity/Azure.Identity/samples/DefiningCustomCredentialTypes.md
Outdated
Show resolved
Hide resolved
sdk/identity/Azure.Identity/samples/DefiningCustomCredentialTypes.md
Outdated
Show resolved
Hide resolved
/// If <see cref="GetToken"/> is called, the provided delegate will be executed sync over async.</param> | ||
/// <returns></returns> | ||
public static TokenCredential Create( | ||
Func<TokenRequestContext, CancellationToken, ValueTask<AccessToken>> getTokenAsync) => new StaticTokenCredential(getTokenAsync); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the func need to return ValueTask
? If not I wonder if Task<AccessToken>
would be easier for users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to keep it 1:1 with GetToken's signature, unless you feel strongly otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly I just wanted to pose the question to others.
#19404
#21940
#19443