Visual FoxPro Requires Chilkat v11.5.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loCurl
LOCAL loAuthorizedCommand1
LOCAL lnHeaderReplacement1
lnSuccess = 0
* Requires Chilkat 11.5.0 or later and a previously unlocked Chilkat bundle.
* See Global Unlock Sample.
* Guide: Box API Guide.
lnSuccess = 0
* 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.
loCurl = CreateObject('Chilkat.HttpCurl')
loCurl.SetVar("access_token","BOX_ACCESS_TOKEN")
loCurl.ClearTargetOutput("*")
loAuthorizedCommand1 = CreateObject('Chilkat.StringBuilder')
loAuthorizedCommand1.SetString('curl -X GET "https://api.box.com/2.0/users/me?fields=id,name,login" -H "Authorization: Bearer {{access_token}}"')
lnHeaderReplacement1 = loAuthorizedCommand1.Replace("{{access_token}}",loCurl.GetVar("access_token"))
lnSuccess = loCurl.DoYourThing(loAuthorizedCommand1.GetAsString())
IF ((lnSuccess <> 1) OR (loCurl.StatusCode <> 200)) THEN
? "Box request failed. HTTP status: " + STR(loCurl.StatusCode)
? "Failure reason: " + STR(loCurl.FailReason)
? loCurl.ResponseBodyStr
RELEASE loCurl
RELEASE loAuthorizedCommand1
CANCEL
ENDIF
? loCurl.ResponseBodyStr
RELEASE loCurl
RELEASE loAuthorizedCommand1