-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Proposal] TokenCredentialRefresher and authenticationOptions #16924
Conversation
@@ -4,6 +4,8 @@ | |||
|
|||
### Features Added | |||
|
|||
- New interface added: `TokenCredentialRefresher`. Represents a credential that can refresh a token over time. |
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.
Please read the description of this PR ✨
Just added this to the description: |
This approach has a considerable problem: we would need to make the refresher way more complicated, to handle caching per scope, and to handle cleaning up previously cached tokens. I’m exploring alternative designs. Here’s another idea: #16940 |
Closed on favor of: #16995 |
This PR is a proposal to solve the concerns related to the OBO credential, and a refactoring of the TokenCycler.
Identity Context:
core-rest-pipeline context:
Proposals in this PR:
authenticationOptions
to the pipelines, in order to swap theTokenCredential
used to authenticate on any client, so that users can call toclient.method({ authenticationOptions: { credential: new Credential() } })
at any time in their code, and swap the credential used to authenticate only for that request.RefreshTokenCredential
abstract class which will encapsulate all of the tokenCycler behavior.refreshToken
which will return a previously obtained token or retrieve a new token if either it’s the first time, or if the cached token is about to expire.TODOs:
getAccessToken
method in core-rest-pipeline’sAuthorizeRequestOptions
and replace it with just acredential: TokenCredential | TokenCredentialRefresher
property. This would be a breaking change on core-rest-pipeline though.RefreshTokenCredential
class. If this approach is good enough, I will move all the other Identity credentials to extend theRefreshTokenCredential
class.This PR also:
Closes #15120