B4X Requires Chilkat v11.5.0+
B4X
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 B4X Downloads
Dim success As Boolean = 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.
Dim curl As ChilkatHttpCurl
curl.Initialize("curl")
curl.SetVar("access_token", "BOX_ACCESS_TOKEN")
curl.ClearTargetOutput("*")
Dim authorizedCommand1 As ChilkatStringBuilder
authorizedCommand1.Initialize
authorizedCommand1.SetString("curl -X GET " & Chr(34) & "https://api.box.com/2.0/users/me?fields=id,name,login" & Chr(34) & " -H " & Chr(34) & "Authorization: Bearer {{access_token}}" & Chr(34))
Dim headerReplacement1 As Int = authorizedCommand1.Replace("{{access_token}}", curl.GetVar("access_token"))
success = curl.DoYourThing(authorizedCommand1.GetAsString)
If (success <> True) Or (curl.StatusCode <> 200) Then
Log("Box request failed. HTTP status: " & curl.StatusCode)
Log("Failure reason: " & curl.FailReason)
Log(curl.ResponseBodyStr)
Return
End If
Log(curl.ResponseBodyStr)