現在認証されているユーザーに関する情報を取得します。
クライアント側で認証されるOAuth 2.0アプリケーションの場合、これはアプリケーションを承認したユーザーになります。
サーバー側でアプリケーションが認証されるJWTの場合、これはデフォルトでアプリケーションに属するサービスアカウントになります。
このAPI呼び出しに使用するユーザーを変更するには、As-User
ヘッダーを使用します。
curl -X GET https://api.box.com/2.0/users/me \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
BoxUser currentUser = await client.UsersManager.GetCurrentUserInformationAsync();
BoxUser user = BoxUser.getCurrentUser(api);
BoxUser.Info info = user.getInfo();
current_user = client.user().get()
client.users.get(client.CURRENT_USER_ID)
.then(currentUser => {
/* currentUser -> {
type: 'user',
id: '33333',
name: 'Example User',
login: 'user@example.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/deprecated' }
*/
});
client.users.getCurrent(fields: ["name", "login"]) { (result: Result<User, BoxSDKError>) in
guard case let .success(user) = result else {
print("Error getting user information")
return
}
print("Authenticated as \(user.name), with login \(user.login)")
}