有没有办法检索当前登录的 Box 用户的user
对象?
我主要关心企业管理员帐户,其中/users
端点被记录为返回所有用户。我如何知道这些用户中的哪一个是提出请求的用户?
对于 V2 API,用户可以在 /users 上调用 GET,您将自己恢复。
{
"total_count": 1,
"entries": [
{
"type": "user",
"id": "13243406",
"name": "Robert Stark",
"login": "rstark@winterfell.com",
"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"
}
]
}
您可以使用 /users/me 端点来获取有关当前用户的信息。
curl https://api.box.com/2.0/users/me
-H "Authorization: Bearer ACCESS_TOKEN"
200
{
"type": "user",
"id": "17738362",
"name": "sean rose",
"login": "sean@box.com",
"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"
}
在 Auth 过程中发生的 get_auth_token 调用中返回有关当前用户的信息。请参阅身份验证下的步骤 4:
<response>
<status>get_auth_token_ok</status>
<auth_token>yv9usmcmbnfhtx2y8rmlvk1csnoz65oo</auth_token>
<user>
<login>joe@example.com</login>
<email>joe@example.com</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>