dropbox / SwiftyDropbox

Swift SDK for the Dropbox API v2.
MIT License
671 stars 207 forks source link

DropboxClientsManager.unlinkClients no longer working as expected #409

Closed vewert closed 2 months ago

vewert commented 2 months ago

I have a screen, where I allow users to remove their Dropbox integration with my app, on which I call DropboxClientsManager.unlinkClients(), which (from what I understand) sets DropboxClientsManager.authorizedClient to nil and should remove Dropbox Integration (this has worked in the past).

If I navigate to a different screen and then back, the client remains nil, but then next time I start the app, and do a check if Dropbox has been integrated (by checking if DropboxClientsManager.authorizedClient is nil), it isn't, so my app thinks that Dropbox Integration/Authorization has been established (even though it was previously unlinked). Then, however, if I proceed to make a call using this client, it gives an error: Bad Input: Error in call to API function "users/get_current_account": Invalid authorization value in HTTP header/URL parameter.

So, for some reason, after unlinking, the next time I start the app the client isn't nil, but still can't be used to make calls.

I am using version SwiftyDropbox 10.0.4, this used to work for older versions.

Note: I use a custom transportClient, when setting up the DropboxClientsManager:

let transportClient: DropboxTransportClientImpl = DropboxTransportClientImpl(
    accessToken: "",
    userAgent: "ipwminder/2.0.6",
    selectUser: nil)

DropboxClientsManager.setupWithAppKey(AppDelegate.appKey, transportClient: transportClient)
if let dbClient: DropboxClient = DropboxClientsManager.authorizedClient {
...
}

If I don't pass in the custom transportClient, i.e. just use:

DropboxClientsManager.setupWithAppKey(AppDelegate.appKey)
if let dbClient: DropboxClient = DropboxClientsManager.authorizedClient {
...
}

it seems to work as expected.

greg-db commented 2 months ago

Thanks for the report! We'll look into it and follow up here with any updates.

greg-db commented 2 months ago

This should be fixed in v10.0.5. Please try that out and let us know if you're still seeing any issues. Thanks!

vewert commented 2 months ago

I did some quick testing, and unlinking works as expected now.

Thanks!