Skip to content

Enable access for token refresh - #31

Merged
daneden merged 15 commits into
daneden:mainfrom
emin-grbo:enable-access-for-token-refresh
Jun 10, 2022
Merged

Enable access for token refresh#31
daneden merged 15 commits into
daneden:mainfrom
emin-grbo:enable-access-for-token-refresh

Conversation

@emin-grbo

Copy link
Copy Markdown
Contributor

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 🙌

emin added 2 commits June 5, 2022 22:42
To enable access of credentials in case of token refresh
To enable immediate storing and/or access of the newly refreshed token.
Comment thread Sources/Twift.swift Outdated
Comment thread Sources/Twift.swift Outdated
Comment thread Sources/Twift.swift Outdated
emin-grbo and others added 2 commits June 6, 2022 14:25
Comment thread Sources/Twift.swift Outdated

/// Initialise an instance with the specified authentication type
public init(_ authenticationType: AuthenticationType) {
public init(_ authenticationType: AuthenticationType, onRefresh: (()-> Void)? = nil) {

Copy link
Copy Markdown
Owner

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.

Copy link
Copy Markdown
Contributor Author

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

Comment thread Sources/Twift.swift Outdated
@emin-grbo

Copy link
Copy Markdown
Contributor Author

Also, made some changes to the tests and all instances where oauth2UserAuth was being called.

@emin-grbo
emin-grbo requested a review from daneden June 7, 2022 19:20
@daneden
daneden merged commit fb6604c into daneden:main Jun 10, 2022
@emin-grbo
emin-grbo deleted the enable-access-for-token-refresh branch June 16, 2022 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants