-
Notifications
You must be signed in to change notification settings - Fork 220
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
Add renew()
to Credentials Manager [SDK-4300]
#772
Conversation
/// | ||
/// - [Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens) | ||
/// - [Authentication API Endpoint](https://auth0.com/docs/api/authentication#refresh-token) | ||
public func renew(parameters: [String: Any] = [:], headers: [String: String] = [:], callback: @escaping (CredentialsManagerResult<Credentials>) -> Void) { |
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.
Should we pass scope here? Is it because we renew anyway if the scope is different?
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.
If a developer wants to downscope, we already have the credentials()
method available, which will force-renew in that case. However, I'm not entirely convinced of the usefulness of this downscoping feature given that the CM does not support multiple sets of credentials, therefore it will overwrite the current credentials with the downscoped ones. So the AT with the full scopes will not be stored anymore. Something to consider for the future.
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.
And we already expose the auth API client method renew()
, that supports downscoping as well (with no storage involved).
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.
LGTM!
📋 Changes
This PR adds a new method
renew()
to the Credentials Manager, that allows to renew the stored credentials in a thread-safe way.This new method also supports Combine and async/await.
🎯 Testing
Besides adding a slew of unit tests, this method was tested manually with Xcode 14.2 (14C18) using an iPhone simulator running iOS 16.2.