Reputation: 13993
Is there any way to retrieve the currently logged in Box user's user
object?
I'm primarily concerned about enterprise admin accounts, where the /users
endpoint is documented as returning all users. How will I know which of these users is the one that made the request?
Upvotes: 1
Views: 3455
Reputation: 211
You can use the /users/me endpoint to get information about the current user.
get-the-current-users-information
curl https://api.box.com/2.0/users/me
-H "Authorization: Bearer ACCESS_TOKEN"
200
{
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "[email protected]",
"created_at": "2012-03-26T15:43:07-07:00",
"modified_at": "2012-12-12T11:34:29-08:00",
"language": "en",
"space_amount": 5368709120,
"space_used": 2377016,
"max_upload_size": 262144000,
"status": "active",
"job_title": "Employee",
"phone": "5555555555",
"address": "555 Office Drive",
"avatar_url": "https://app.box.com/api/avatar/large/17738362"
}
Upvotes: 3
Reputation: 2599
For the V2 API, a user can call GET on /users and you will get yourself back.
{
"total_count": 1,
"entries": [
{
"type": "user",
"id": "13243406",
"name": "Robert Stark",
"login": "[email protected]",
"created_at": "2011-08-24T14:00:25-07:00",
"modified_at": "2012-10-10T04:32:24-07:00",
"role": "user",
"language": "en",
"space_amount": 53687091200,
"space_used": 48671461,
"max_upload_size": 104857600,
"tracking_codes": [],
"see_managed_users": false,
"sync_enabled": true,
"status": "active",
"job_title": "",
"phone": "",
"address": "",
"avatar_url": "https://api.box.com/api/avatar/large/13243406"
}
]
}
Upvotes: 4
Reputation: 2485
Information about the current user is returned in the get_auth_token call that occurs during the Auth process. See Step 4 under Authentication:
<response>
<status>get_auth_token_ok</status>
<auth_token>yv9usmcmbnfhtx2y8rmlvk1csnoz65oo</auth_token>
<user>
<login>[email protected]</login>
<email>[email protected]</email>
<access_id>31313825</access_id>
<user_id>31313825</user_id>
<space_amount>5361200</space_amount>
<space_used>47477</space_used>
<max_upload_size>104800</max_upload_size>
<sharing_disabled/>
</user>
</response>
Upvotes: 0