We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
asharma327
7 years agoNew member | Level 2
Get User ID from Chooser API
In my app, I am using the OAuth properly and am able to interact with a user's file (read, write etc). My flow is currently:
1. Get access_token by having the user allow the app access to their account and calling this endpoint
https://api.dropbox.com/oauth2/token
2. Have user select files from the Chooser
3. Use the access_token and file information to perform the necessary operations
However, now there is a requirement to support multiple dropbox accounts per user. I can once again use the token endpoint to get the access_token for each account, but I am lost on how to get the account ID when the user interacts with the chooser so I can relate each file with the proper access_token. Is there an endpoint or option on the chooser to get the account ID on what the logged in account is when the user opens the Chooser?
No, I'm afraid there isn't anything quite like that either. (The Chooser wasn't originally designed to be used together with the API, so there isn't much interoperability.)
There are a few ways you can try, though they're not ideal and won't be 100% reliable for this:
- Once you have the file ID, try calling /2/files/get_metadata with the file ID using each of the access tokens you have. If the account has access to the file, you'll get the metadata back. If not, you'll get an error.
- Once you have the shared link, try calling /2/sharing/get_shared_link_metadata with the shared link using each of the access tokens you have. If the link owner is a team member of the same team as the connected account for that access token, `team_member_info` will be set.
4 Replies
- Greg-DB7 years ago
Dropbox Community Moderator
No, unfortunately there isn't a way to get the account ID from the Chooser like this, but I'll pass this along as a feature request. I'm not currently aware of any plans to implement this though.
- asharma3277 years agoNew member | Level 2
Ah shucks :(
Per chance, is there any way to get the user info from the file info? For example, maybe get the account ID from the file ID or file link from another API endpoint?
- Greg-DB7 years ago
Dropbox Community Moderator
No, I'm afraid there isn't anything quite like that either. (The Chooser wasn't originally designed to be used together with the API, so there isn't much interoperability.)
There are a few ways you can try, though they're not ideal and won't be 100% reliable for this:
- Once you have the file ID, try calling /2/files/get_metadata with the file ID using each of the access tokens you have. If the account has access to the file, you'll get the metadata back. If not, you'll get an error.
- Once you have the shared link, try calling /2/sharing/get_shared_link_metadata with the shared link using each of the access tokens you have. If the link owner is a team member of the same team as the connected account for that access token, `team_member_info` will be set.
- asharma3277 years agoNew member | Level 2
Gotcha, I was thinking of doing something along those lines. Thanks Greg
About Discuss Dropbox Developer & API
Make connections with 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!
Related Content
- 4 years agoanonymous