Skip to content
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

Fix custom transport client auth state #411

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

julianlocke
Copy link
Contributor

As noted in this GitHub issue the singleton that 3p developers use to set up their clients behaves incorrectly when the setup method is called with a non-nil transport client when an access token is not persisted.

In sdk versions < 10 we always checked to see if there was an access token before initializing an authorized client, and that logic was lost in a refactor. This PR restored that logic.

Additionally, it adds parity between the differently timed setup methods, adding the ability to pass in a transport client to the reauth*Client methods, and adding a handleRedirectURL flavor that matches the flavors of the setup methods that just take session and container identifiers.

Copy link

@jaquish jaquish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, see comments

requestsToReconnect: requestsToReconnect
)
if let token = token(for: oauthSetupIntent.userKind, using: oAuthManager) {
setUpAuthorizedClient(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an error logged for no token?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually a valid state, the model here is that users should call the setup* function on every launch. Auth can be performed afterwards if needed.

@@ -136,33 +141,34 @@ public class DropboxClientsManager {
}
}

public static func reauthorizeClient(_ tokenUid: String, sessionConfiguration: NetworkSessionConfiguration? = nil) {
public static func reauthorizeClient(_ tokenUid: String, sessionConfiguration: NetworkSessionConfiguration? = nil, transportClient: DropboxTransportClient? = nil) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: put args in the same order as setupAuthorizedClient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nice catch

@julianlocke julianlocke merged commit 91861a0 into master Mar 15, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants