React Native Requires Chilkat v11.5.0+
React Native
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 React Native Downloads
import { HttpCurl, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
let success = false;
// Requires Chilkat 11.5.0 or later and a previously unlocked Chilkat bundle.
// See Global Unlock Sample.
// Guide: Box API Guide.
success = false;
// 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.
const curl = new HttpCurl();
curl.setVar('access_token', 'BOX_ACCESS_TOKEN');
curl.clearTargetOutput('*');
const authorizedCommand1 = new StringBuilder();
authorizedCommand1.setString('curl -X GET "https://api.box.com/2.0/users/me?fields=id,name,login" -H "Authorization: Bearer {{access_token}}"');
const headerReplacement1 = authorizedCommand1.replace('{{access_token}}', curl.getVar('access_token'));
success = true;
try {
await curl.doYourThingAsync(authorizedCommand1.getAsString());
} catch {
success = false;
}
if ((!success) || (curl.statusCode !== 200)) {
console.log(`Box request failed. HTTP status: ${curl.statusCode}`);
console.log(`Failure reason: ${curl.failReason}`);
console.log(curl.responseBodyStr);
return;
}
console.log(curl.responseBodyStr);
}