-
Notifications
You must be signed in to change notification settings - Fork 208
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
Conversation
…ransport clients on re-auth
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, see comments
requestsToReconnect: requestsToReconnect | ||
) | ||
if let token = token(for: oauthSetupIntent.userKind, using: oAuthManager) { | ||
setUpAuthorizedClient( |
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 there be an error logged for no token?
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.
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) { |
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.
nit: put args in the same order as setupAuthorizedClient
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.
ah, nice catch
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.