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
Moved to API forum.
Are you sure the user has completed the auth flow? Maybe check that you have a valid access token with DropboxAuthManager.sharedAuthManager.hasStoredAccessTokens()
or by printing DropboxAuthManager.sharedAuthManager.getAllAccessTokens()
?
Thanks Leah. Yes the user has completed the auth flow.
DropboxAuthManager.sharedAuthManager.hasStoredAccessTokens() is true
And DropboxAuthManager.sharedAuthManager.getAllAccessTokens() contains my token.
Hmmm... this could also happen if the access token has been revoked. Maybe try Dropbox.unlinkClient()
and re-authorizing?
That worked. Is there any way to guard/check for a revoked token?
There's no way to know if a token has been revoked until you make an API call. You'll need to look for a 401 error response and then call Dropbox.unlinkClient()
to clear the bad tokens.
Hi Leah,
I am just following up on this again as I've had a couple of issues along the way. The main issue I've had is not being able to call Dropbox after auth. It happens if it's the first time I auth or if I call Dropbox.unlinkClient()
then re-auth. The problem seems to be the same - Dropbox.authorizedClient
and DropboxClient.sharedClient
are nil
.
I also didn't like that the 401 was embedded in the error string. I added an extension to make the http code more easily accessible and to handle the unlinking. I've ended up wrapping SwiftyDropbox (https://gist.github.com/p15martin/82cbae8188729f26fbbb).
Interested in your thoughts?
-Peter
Just to clarify, Dropbox a user is authorized by clicking a link in your app which calls Dropbox.authorizeFromController(controller)
. This presents a web view for the user to login and afterwards, you're calling Dropbox.handleRedirectURL(url)
which handles storing the access token for the user. There's no need to set or get access tokens manually - just be sure to call Dropbox.handleRedirectURL(url)
in your AppDelegate's
method (this isn't shown in your gist but I'm assuming you're doing this??). Does that help clear things up?
- application:openURL:sourceApplication:annotation:
I'll pass along the feedback about the error object to the team. Thanks!
Thanks. Yes I am calling Dropbox.handleRedirectURL(url)
in my app delegate.
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!