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

Filip J.1's avatar
Filip J.1
New member | Level 1
9 years ago

Get Account Id from UserInfoMembership using Team Client .NET

I am using a dropbox admin account and using ListFolderMembersAsync and grabbing the UserMemberShipInfo which returns UserInfo. When I get this data returned some of the accounts have TeamMemberId while some have AccountId.

TeamMemberId is not always returned with this api call. How do I do an api call to get the account information using UserInfo if I am using a TeamClient. If I try to use a regular AccountId instead of TeamMemberId I get an exception stating:

This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team.

So how to I get the account information when the teamMemberid is not always returned with the call and I am using a team client.

 

Basically, how do I get account information when I only have the accountId and am using a TeamClient for an admin account?

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    UserInfo.TeamMemberId is documented as "The team member ID of the shared folder member. Only present if SameTeam is true.", meaning it will only be present if "the user is in the same team as current user." The "current user" here is the user you're making the ListFolderMembersAsync call for. (That is, by setting AsMember on the team client.)

    When you say you "try to use a regular AccountId instead of TeamMemberId", where are you supplying the account ID? 

    If you just want information about that other user, what you should do is call GetAccountAsync with the account ID you're interested in as the accountId parameter, using a team client with AsMember still set to the same member that you used to call ListFolderMembersAsync in the first place. (If the user for the accountId isn't on the same team, you don't have authorization to make calls on their behalf, using AsMember, anyway.)

    If you're still having trouble, please share some code that shows the issue.

  • Filip J.1's avatar
    Filip J.1
    New member | Level 1

    If I have a fileMetaData object and grab the fileItem.SharingInfo.ModifiedBy it will return the id of the account that last modified the file.

    How do I get the information of this account if I only have the this accountId and no longer have access to the asMember id? 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The same as the other scenario, if you have an account ID and you want information about that account, you'll need to call GetAccountAsync. That is a user endpoint though, so you do need to use AsMember if you have a team client. What do you mean when you say you "no longer have access to the asMember id" though? Can't you just use the same team client with asMember set that you used to retrieve the file metadata itself?

  • Filip J.1's avatar
    Filip J.1
    New member | Level 1

    I could, but I haven't passed it down in my functions and am wondering if I can do without it.

    It seems redundant that I need to use memberId to make calls for GetAccountAsync. The function takes in an accountId to search for. Whether I make the call from Team Member A or Team Member B does not affect the output, why force users to have a memberId if the output in this case is not dependent on it? 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The API call itself is a user endpoint (as opposed to a team endpoint). User endpoints require a user in general, even if it doesn't matter in this particular case.

  • Filip J.1's avatar
    Filip J.1
    New member | Level 1

    So there is no team endpoint that allows you to get account information without using AsMember? 

About Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,875 PostsLatest Activity: 3 hours ago
323 Following

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 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!