Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
In the Android Core API v2 SDK, when a Dropbox access token becomes invalid, I want to catch that exception and null out my copy of the access token so the linking authorization will be done again. The trouble is, I don't know how to exactly qualify that particular exception. For testing purposes I have deliberately fed the wrong access token to the API (rather than invalidate the actual token with Dropbox). For me, the exception happens on listFolder(). And the exception thrown is the DbxException. Buy why isn't it the InvalidAccessTokenException? Apparently that is a real thing, a subclass of DbxException. But it does not check with:
if(e instanceof InvalidAccessTokenException)
but only with:
if(e instanceof DbxException)
If there are any other reasons for any of these API functions to throw a DbxException besides an invalid access token, it would be wrong for me to pretend that the access token is the only problem. So I would like to detect when this specific exception is thrown, as distinct from all others.
InvalidAccessTokenException does get thrown for me when calling listFolder with an invalid access token. (Both catching InvalidAccessTokenException and using instanceof work as expected in my test.)
Can you share your code that reproduces this? What version of the SDK do you have installed?
Also, please print and share the stack trace for the exception you do get. Thanks in advance!
Maybe it is the way I faked the invalid token. Instead of passing a real, but invalidated token, I passed
"Z" + validToken
to the "new DbxClientV2(requestConfig, DBaccessToken);" API call. So it has one more letter than the real token. And the message with that exception is "OAuth2 token is mal-formed". I'll bet that's it.
Yes, that would do it. That gives you that BadRequestException instead, since the token is recognizably not the right format. If instead you just modify an existing character in the access token in place you can force the InvalidAccessTokenException instead.
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!