We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.
Forum Discussion
Robert S.138
9 years agoHelpful | Level 7
iOS: Detect when DBError is "Invalid Access Token"
I need to determine when a DBError instance returned from listFolder: or downloadData: is because of an Invalid Access Token. So far I can see how to transform the DBError into a DBRequestAuthError using:
[error asAuthError]
provided [error isAuthError]. And I can see how to check for Invalid Access Token in an instance of DBAuthError using [... isInvalidAccessToken]. But I don't know how to get from a DBRequestAuthError to a DBAuthError. isInvalidAccessToken: does not apply to class DBRequestAuthError.
- Greg-DBDropbox Staff
Hi Robert, it sounds like you're looking for the structuredAuthError property on DBRequestAuthError. That will give you the DBAUTHAuthError, on which you can call isInvalidAccessToken etc. E.g.:
if (authError.structuredAuthError.isInvalidAccessToken) {
NSLog(@"Invalid acess token.");
}Hope this helps!
- Robert S.138Helpful | Level 7
Yes, that compiles without errors. I am doing this:
if( [dbError isAuthError] ) {
DBRequestAuthError* dbAuthError = [dbError asAuthError];
if (dbAuthError.structuredAuthError.isInvalidAccessToken) {
//..handle Invalid Access Token Error
}
}where dbError is the instance of DBError returned by the API. But I am also curious about the need for the method "asAuthError". Could I not just as well do this:
if( [dbError isAuthError] ) {
if (dbError.structuredAuthError.isInvalidAccessToken) {
//..handle Invalid Access Token Error
}
}This also compiles without any errors or warnings. Will it work?
- Greg-DBDropbox Staff
I believe either way is safe as long as you have that isAuthError check. The asAuthError call just gives you the object as DBRequestAuthError instead of DBRequestHttpError, but it doesn't seem to make a difference in this case.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,875 PostsLatest Activity: 2 hours agoIf 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 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!