Objective-C Requires Chilkat v11.5.0+
Objective-C
Box: Identify the User Behind an Access Token
See more Box Examples
Identify the account whose permissions and root folder the token uses. Start here when an app cannot see files visible in a personal Box account.
See the Box API guide for setup and the complete workflow.
Chilkat Objective-C Downloads
#import <CkoHttpCurl.h>
#import <CkoStringBuilder.h>
BOOL success = NO;
// Requires Chilkat 11.5.0 or later and a previously unlocked Chilkat bundle.
// See Global Unlock Sample.
// Guide: Box API Guide.
success = NO;
// Supply an unexpired token obtained with one of the Box authentication examples.
// A token represents a particular user or service account. IDs must be accessible to it.
CkoHttpCurl *curl = [[CkoHttpCurl alloc] init];
[curl SetVar: @"access_token" varValue: @"BOX_ACCESS_TOKEN"];
[curl ClearTargetOutput: @"*"];
CkoStringBuilder *authorizedCommand1 = [[CkoStringBuilder alloc] init];
[authorizedCommand1 SetString: @"curl -X GET \"https://api.box.com/2.0/users/me?fields=id,name,login\" -H \"Authorization: Bearer {{access_token}}\""];
int headerReplacement1 = [[authorizedCommand1 Replace: @"{{access_token}}" replacement: [curl GetVar: @"access_token"]] intValue];
success = [curl DoYourThing: [authorizedCommand1 GetAsString]];
if ((success != YES) || ([curl.StatusCode intValue] != 200)) {
NSLog(@"%@%d",@"Box request failed. HTTP status: ",[curl.StatusCode intValue]);
NSLog(@"%@%d",@"Failure reason: ",[curl.FailReason intValue]);
NSLog(@"%@",curl.ResponseBodyStr);
return;
}
NSLog(@"%@",curl.ResponseBodyStr);