-
Notifications
You must be signed in to change notification settings - Fork 26
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
Enable access for token refresh #31
Enable access for token refresh #31
Conversation
To enable access of credentials in case of token refresh
To enable immediate storing and/or access of the newly refreshed token.
Co-authored-by: Daniel Eden <dan.eden@me.com>
Sources/Twift.swift
Outdated
|
||
internal let decoder: JSONDecoder | ||
internal let encoder: JSONEncoder | ||
|
||
/// Initialise an instance with the specified authentication type | ||
public init(_ authenticationType: AuthenticationType) { | ||
public init(_ authenticationType: AuthenticationType, onRefresh: (()-> Void)? = nil) { |
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.
Seeing this now, it actually makes more sense to have onRefresh
associated with the AuthenticationType
:
enum AuthenticationType {
case oauth2User(user: OAuth2User, onRefresh: (() -> Void)?)
...
}
Alternatively, we might want to move to different initialisers for different authentication types. That might actually be nicer from an author perspective.
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 see, yeah, makes sense
Should we then even make it non-optional? I am not sure what the case would be where one would not need a refresh of the token?
I made some changes to the refreshOAuth2AccessToken
and moved refreshCompletion
from the init to the AuthenticationType
Co-authored-by: Daniel Eden <dan.eden@me.com>
…roblack/Twift into enable-access-for-token-refresh
Also, made some changes to the tests and all instances where |
As discussed in the issue, enabling access of the
oauthUser
along with the addition of an optional callback.#30
Hope it makes sense and this is what you had in mind 🙌