You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Bob S.15
8 years agoCollaborator | Level 9
migrating from API 1 to 2 - how do I know if I have OAuth 1 tokens?
I am finally getting around to updating my OLD apps from the original Dropbox IOS API to the new one. I'm looking at the migration guide, and the first thing it says is to check my OAuth tokens to se...
Bob S.15
Collaborator | Level 9
Hey Greg,
That's great, thanks! That code works, but I think I am missing one step. After I go through and store the new tokens, how do I get it to recognize that it is authorized? I am finding that [DropboxClientsManager authorizedClient] is returning nil after storing the tokens. If I quit the app and then run it again, THEN it recognizes the app as being authorized. But how do I get it to know it's authorized without having to restart the app?
Another question if you do not mind. I am making progress with the SDK and have been able to upload files. But I don't understand why some DBFILESRoutes functions list two arguments for the return response, but they seem to require three in practice. For example -createFolder:autorename says it returns a DBFILESFolderMetadata object and a DBFILESCreateFolderError object, but XCode gives me an error unless there is also a third DBRequestError object. Is this a documentation mistake or is the third argument assumed but not shown for some reason?
Thanks!
Bob
Greg-DB
8 years agoDropbox Staff
I believe you can get that active within the same session using DropboxClientsManager.reauthorizeClient. Let me know if that doesn't work for you though.
Yes, the third one, a DBRequestError, applies to all calls and covers higher level failures (network issues, invalid access tokens, etc.) so it's not documented on each call individually.
- Bob S.158 years agoCollaborator | Level 9
Hey Greg,
Yes that worked, thanks!
In the process of debugging this I went through all of my various simulators and devices, because I don't know how to remove the OAuth2 tokens once they are on there. I ran the old app to get the old tokens installed, then ran the new one to test the retrieval. Is there any way to remove the new tokens in order to re-test the transfer?
Bob
- Greg-DB8 years agoDropbox Staff
Yea, you can use DBOAuthManager.clearStoredAccessToken for specific tokens, or DBOAuthManager.clearStoredAccessTokens for all tokens.
- Bob S.158 years agoCollaborator | Level 9
Ok, thanks Greg.
Also, when I use DBFILESgetMetadata, is there any way to tell if the path is a file or a folder? In the old SDK there was an 'isDirectory' field of the metadata structure, but I don't see one for DBFILESMetadata. ?
Also, if it IS a folder, then how do you access the contents of the folder? With the old SDK I uses a loop like this:
for (DBMetadata *file in metadata.contents)
Thanks
Bob
- Greg-DB8 years agoDropbox StaffYou can use isKindOfClass to check the type:
https://github.com/dropbox/dropbox-sdk-obj-c/blob/8d4fcca08a6673af35cf6e116810b13e3e6507e9/README.md#response-handling-edge-cases - Bob S.158 years agoCollaborator | Level 9
OK thanks, and how would you access the contents of the folder, is that included in the metadata or do you have to issue another call to get that? Would I have to use listFolder?
- Greg-DB8 years agoDropbox StaffYes, you should use listFolder (and listFolderContinue) to get the contents of any given folder.
- Bob S.158 years agoCollaborator | Level 9
Hey Greg,
If getMetaData returns an error, how do you retrieve the error information from DBFILESGetMetadataError? It looks like it only contains a path and a tag, and I can't tell what the tag is. The docs say it represents the "union's current tag state", but it doesn't show any values. Is there some other way to get information about why it failed or what the error is ?
Thanks,
Bob
- Greg-DB8 years agoDropbox StaffYou can use the "is" methods to check which member of the error union a particular instance of the error is, then you can access the respective property for the specific error value, as shown here:
https://github.com/dropbox/dropbox-sdk-obj-c#route-specific-errors
The documentation details which methods/properties are available for any given type, e.g., for DBFILESGetMetadataError:
https://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESGetMetadataError.html - Bob S.158 years agoCollaborator | Level 9
Thanks for the reply. I get that I can use the 'is' commands to check the error, but in the case of the metadata, there is a path and a tag. The path is pretty self evident. But what is the tag? The docs don't seem to provide any details about what that is. I'm just wondering in the case of an error, how I would go about determining the cause or reason. The path I already know. And it doesn't look like the tag tells me anything. Does that make sense?
Thanks!
- Greg-DB8 years agoDropbox Staff
The "tag" is the way the API describes which member of the union the object is. The SDK uses it to determine what the "is" methods return. So, you don't need to access tag directly, as long as you use the "is" methods.
To get the actual error information, use the respective field. For example, DBFILESGetMetadataError.path gives you a DBFILESLookupError, which itself has various "is" methods to tell you which error it was (and so on, for any further nested errors).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,888 PostsLatest Activity: 2 days 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!