Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Peter M.107
10 years agoNew member | Level 1
SwiftyDropbox (v0.2) - invalid_access_token
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-v2/).
When I try and do something (e.g. client.usersGetCurrentAccount()) I get an HTTP error: invalid_access_token
Any help would be appreciated.
-Peter
16 Replies
Replies have been turned off for this discussion
- Peter M.10710 years agoNew member | Level 1
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. - Leah C.110 years agoNew member | Level 1
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_tokenand 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
LeahI 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?
- Peter M.10710 years agoNew member | Level 1
In the code I shared I have a fix. In
AppDelegateunderDropbox.handleRedirectURL(url), I am callingself.dropbox.verifyConnectionAfterAuth()which reconnectsDropbox.authorizedClientandDropboxClient.sharedClient. Try commenting it out and see if you get the problem. - Leah C.110 years agoNew member | Level 1
One thing you could do to improve this is in your AppDelegate's
- application:openURL:sourceApplication:annotation:try usingDropbox.handleRedirectURL(url)instead of the lower-level methodDropboxAuthManager.sharedAuthManager.handleRedirectURL(url). This will set theDropbox.authorizedClientfor you, so you don't need to do it yourself: https://github.com/dropbox/SwiftyDropbox/blob/master/Source/DropboxClient.swift#L67The
Dropboxclass is really just a helpful wrapper around theDropboxAuthManagerfor the case where you only expect one account to be authorized at a time. - Peter M.10710 years agoNew member | Level 1
That resolves the problem! Thanks!
- Leah C.110 years agoNew member | Level 1
Oh good. Thanks so much for your feedback too!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!