Classic ASP Requires Chilkat v11.5.0+
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Requires Chilkat 11.5.0 or later and a previously unlocked Chilkat bundle.
' See Global Unlock Sample.
' Guide: Box API Guide.
success = 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.
set curl = Server.CreateObject("Chilkat.HttpCurl")
curl.SetVar "access_token","BOX_ACCESS_TOKEN"
curl.ClearTargetOutput "*"
set authorizedCommand1 = Server.CreateObject("Chilkat.StringBuilder")
success = authorizedCommand1.SetString("curl -X GET ""https://api.box.com/2.0/users/me?fields=id,name,login"" -H ""Authorization: Bearer {{access_token}}""")
headerReplacement1 = authorizedCommand1.Replace("{{access_token}}",curl.GetVar("access_token"))
success = curl.DoYourThing(authorizedCommand1.GetAsString())
If ((success <> 1) Or (curl.StatusCode <> 200)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Box request failed. HTTP status: " & curl.StatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Failure reason: " & curl.FailReason) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( curl.ResponseBodyStr) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( curl.ResponseBodyStr) & "</pre>"
%>
</body>
</html>