cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Get User ID from Chooser API

Get User ID from Chooser API

asharma327
New member | Level 2
Go to solution

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? 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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:

  1. 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.
  2. 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.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

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.

asharma327
New member | Level 2
Go to solution

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-DB
Dropbox Staff
Go to solution

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:

  1. 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.
  2. 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.

asharma327
New member | Level 2
Go to solution

Gotcha, I was thinking of doing something along those lines. Thanks Greg

Need more support?