You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
George M.33
10 years agoNew member | Level 1
SwiftyDropbox: "Client is already authorized"
I am calling setupWithAppKey in application:didFinishLaunching. Seems fine.
Then, I call Dropbox.authorizeFromController from my viewController, and I immediately get this error:
precondition failed: Client is already authorized: file /Users/gmadrid/Desktop/feedfile/Pods/SwiftyDropbox/Source/DropboxClient.swift, line 58
It I comment out the precondition on line 58, I get bit in handleRedirectURL() at line 64. Same error.
Looking at the code, I see why it breaks. setupWithAppKey sets the "authorizedClient" at line 51, so that precondition is always doomed to fail.
Any thoughts on how to proceed or what I might be doing wrong?
Thanks,
George
- George M.33New member | Level 1
Follow up.
Commenting out the preconditions at lines 58 and 64 results in everything seeming to work. I am able to successfully make a call to filesListFolder.
Also, the token that it's finding at line 50 (DropboxAuthManager.sharedAuthManager.getFirstAccessToken()) belongs to uid "engine-state"
Thanks.
-g
- Steve M.Dropbox Staff
That class is meant to be used in the case where there's only a single user being authorized.
Are you trying to authorize multiple users? If so, you'll need to use the DropboxAuthManager directly.
If you do just want a single user (but want to forget about the user who's already been authorized), you can use unlinkClient.
- George M.33New member | Level 1
Thanks for the suggestion. I'm only using a single user.
I _think_ this is related to using the simulator for debugging, but I'm not sure. Tracing through the code on a brand-new reset simulator finds two entries already in the keychain. These are what are screwing things up.
Things seem to work fine on a device.
I have patched in a workaround in my local copy of the SwiftyDropbox code. This workaround is entirely unsuitable for submission, but it's gotten me unblocked.
- Leah C.1New member | Level 1
Did you previously try out the Swift SDK in the simulator? That would explain having entries already in the keychain. I'm not sure why they wouldn't be deleted when resetting the simulator though... that's odd.
You can always use `Dropbox.unlinkClient()` in your code to clear the credentials.
This shouldn't affect running the code on a device or with other users.
- George M.33New member | Level 1
Hi Leah,
Thanks for your response. I've tried resetting and unlinkClient(). Neither one helps the situation. I have a sneaky suspicion that it has something to do with the particular machine that I'm on, because it seems to all work on my laptop (but not my desktop). My suspicion is that the data in my desktop's keychain is interfering with the responses in the simulator. Some of the stuff that I've read (in StackOverflow for e.g.) suggests that keychain is broken in the simulator.
I'll play with it a little and see if I can repro on my laptop. Then I'll have some instructions for y'all.
Thanks,
-g
- Leah C.1New member | Level 1
Reply if you find out anything new... it would be super helpful!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,919 PostsLatest Activity: 13 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!