Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi,
I'm trying out SwiftyDropbox and following the code given in the blogpost (https://blogs.dropbox.com/developers/2015/05/try-out-swiftydropbox-the-new-swift-sdk-for-dropbox-api...).
When I try and do something (e.g. client.usersGetCurrentAccount()
) I get an HTTP error: invalid_access_token
Any help would be appreciated.
-Peter
Could you also include the code from the view controller where you're calling the DropboxAPI methods? Maybe also include your AppDelegate code? I tested the code from the blog post this morning and it appears to be working okay. Are you doing anything differently for your app?
Here's the code: https://github.com/p15martin/DropboxStream
I can re-create the issue consistently. Grab the token. Call https://api.dropbox.com/1/disable_access_token. Restart the app.
Thanks for the code!
This is odd but I'm seeing nothing wrong. I'm able to link to Dropbox successfully. Here's the console output: https://www.dropbox.com/s/mttaf63iotmhan7/Screenshot%202015-06-17%2011.01.49.png?dl=0
Each time I re-open the app, everything works fine too: https://www.dropbox.com/s/zhvvoj39dup7z4z/Screenshot%202015-06-17%2011.02.11.png?dl=0
If I call /disable_access_token
and re-open the app, I'm prompted to log in again, but then everything works as expected. Here's the console output:
Init dropbox
Has client
Token has expired
(note, at this point I'm prompted to re-auth)
Success! User is logged into Dropbox.
Reconnecting the account
Has client
Leah
I wonder if it's an issue with the Dropbox account that you're using to test the app. Are you testing the app with the same account you used to create the app in the Dropbox app console?
In the code I shared I have a fix. In AppDelegate
under Dropbox.handleRedirectURL(url)
, I am calling self.dropbox.verifyConnectionAfterAuth()
which reconnects Dropbox.authorizedClient
and DropboxClient.sharedClient
. Try commenting it out and see if you get the problem.
One thing you could do to improve this is in your AppDelegate's - application:openURL:sourceApplication:annotation:
try using Dropbox.handleRedirectURL(url)
instead of the lower-level method DropboxAuthManager.sharedAuthManager.handleRedirectURL(url)
. This will set the Dropbox.authorizedClient
for you, so you don't need to do it yourself: https://github.com/dropbox/SwiftyDropbox/blob/master/Source/DropboxClient.swift#L67
The Dropbox
class is really just a helpful wrapper around the DropboxAuthManager
for the case where you only expect one account to be authorized at a time.
That resolves the problem! Thanks!
Oh good. Thanks so much for your feedback too!
Hi there!
If you need more help you can view your support options (expected response time for a 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!