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.
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.
I wanted to keep it 1:1 with GetToken's signature, unless you feel strongly otherwise
There was a problem hiding this comment.
I don't feel strongly I just wanted to pose the question to others.
#19404
#21940
#19443