cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you an educator? Well we want to hear from you, so check out some tools we think might help you out here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SwiftyDropbox: "Client is already authorized"

SwiftyDropbox: "Client is already authorized"

George M.33
New member | Level 1

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

 

6 Replies 6

Re: SwiftyDropbox: "Client is already authorized"

George M.33
New 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

 

Re: SwiftyDropbox: "Client is already authorized"

Steve M.
Dropboxer

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.

Re: SwiftyDropbox: "Client is already authorized"

George M.33
New 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.

 

Re: SwiftyDropbox: "Client is already authorized"

Leah C.1
New 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.

Re: SwiftyDropbox: "Client is already authorized"

George M.33
New 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

 

Re: SwiftyDropbox: "Client is already authorized"

Leah C.1
New member | Level 1

Reply if you find out anything new... it would be super helpful!

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Leah C.1 New member | Level 1
  • User avatar
    George M.33 New member | Level 1
  • User avatar
    Steve M. Dropboxer
What do Dropbox user levels mean?
Need more support?