Foxpro / Bond APIs / Get Auth Token
Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL loDate_created
LOCAL loDate_updated
LOCAL loDate_revoked
LOCAL loDate_expired
LOCAL lcIdentity
LOCAL lcKey_name
LOCAL lcRole_id
LOCAL lcRole_name
LOCAL lcOrg_id
LOCAL lcGrantor
LOCAL lcGrantee
LOCAL lcStatus
LOCAL lnCall_count
LOCAL lcLast_call
LOCAL lcLast_auth
LOCAL lcLast_used
LOCAL lcLast_method
LOCAL lcLast_route
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("Authorization","{{authorization}}")
loHttp.SetRequestHeader("Identity","{{identity}}")
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://{{environment}}.bond.tech/api/v0/auth/key/{{identity}}",loSbResponseBody)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loSbResponseBody
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loHttp.LastHeader
? "Failed."
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "identity": "a927213f-514c-49b3-a5a6-f9448bb57e9e",
* "key_name": "xyz_key",
* "role_id": "7e9d7292-2dd9-458b-9847-bc7fec065369",
* "role_name": "OS_FULL_ACCESS",
* "org_id": "073dff15-8bfe-4f00-9f55-c05ad0927cee",
* "grantor": "89e851fa-a7f4-4058-998c-4bd2d8b19b7a",
* "grantee": "ba272a5f-3f90-46da-a2fa-5d433629fcb2",
* "date_created": "2020-11-13 21:09:18.244428+00:00",
* "date_updated": "2020-11-20 19:35:29.180389+00:00",
* "date_revoked": "",
* "date_expired": "",
* "status": "active",
* "call_count": 197,
* "last_call": "2020-11-20 19:35:29.179258+00:00",
* "last_auth": "S",
* "last_used": "2020-11-20 19:35:29.179548+00:00",
* "last_method": "unknown",
* "last_route": "unknown"
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.DtObj')
loDate_created = CreateObject('Chilkat.DtObj')
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.DtObj')
loDate_updated = CreateObject('Chilkat.DtObj')
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.DtObj')
loDate_revoked = CreateObject('Chilkat.DtObj')
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.DtObj')
loDate_expired = CreateObject('Chilkat.DtObj')
lcIdentity = loJResp.StringOf("identity")
lcKey_name = loJResp.StringOf("key_name")
lcRole_id = loJResp.StringOf("role_id")
lcRole_name = loJResp.StringOf("role_name")
lcOrg_id = loJResp.StringOf("org_id")
lcGrantor = loJResp.StringOf("grantor")
lcGrantee = loJResp.StringOf("grantee")
loJResp.DtOf("date_created",0,loDate_created)
loJResp.DtOf("date_updated",0,loDate_updated)
loJResp.DtOf("date_revoked",0,loDate_revoked)
loJResp.DtOf("date_expired",0,loDate_expired)
lcStatus = loJResp.StringOf("status")
lnCall_count = loJResp.IntOf("call_count")
lcLast_call = loJResp.StringOf("last_call")
lcLast_auth = loJResp.StringOf("last_auth")
lcLast_used = loJResp.StringOf("last_used")
lcLast_method = loJResp.StringOf("last_method")
lcLast_route = loJResp.StringOf("last_route")
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
RELEASE loDate_created
RELEASE loDate_updated
RELEASE loDate_revoked
RELEASE loDate_expired
Curl Command
curl -X GET
-H "Content-Type: application/json"
-H "Authorization: {{authorization}}"
-H "Identity: {{identity}}"
https://{{environment}}.bond.tech/api/v0/auth/key/{{identity}}
Postman Collection Item JSON
{
"name": "Get Auth Token",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"type": "text",
"value": "{{authorization}}"
},
{
"key": "Identity",
"type": "text",
"value": "{{identity}}"
}
],
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/auth/key/{{identity}}",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"auth",
"key",
"{{identity}}"
]
},
"description": "Add Card financial Core"
},
"response": [
{
"name": "example",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"type": "text",
"value": "{{Authorization}}"
},
{
"key": "Identity",
"type": "text",
"value": "{{Identity}}"
}
],
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/auth/key/a927213f-514c-49b3-a5a6-f9448bb57e9e",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"auth",
"key",
"a927213f-514c-49b3-a5a6-f9448bb57e9e"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Content-Length",
"value": "691"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Server",
"value": "gunicorn/19.9.0"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Date",
"value": "Fri, 20 Nov 2020 19:35:29 GMT"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "X-Served-By",
"value": "cache-pao17424-PAO"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31557600"
}
],
"cookie": [
],
"body": "{\n \"identity\": \"a927213f-514c-49b3-a5a6-f9448bb57e9e\",\n \"key_name\": \"xyz_key\",\n \"role_id\": \"7e9d7292-2dd9-458b-9847-bc7fec065369\",\n \"role_name\": \"OS_FULL_ACCESS\",\n \"org_id\": \"073dff15-8bfe-4f00-9f55-c05ad0927cee\",\n \"grantor\": \"89e851fa-a7f4-4058-998c-4bd2d8b19b7a\",\n \"grantee\": \"ba272a5f-3f90-46da-a2fa-5d433629fcb2\",\n \"date_created\": \"2020-11-13 21:09:18.244428+00:00\",\n \"date_updated\": \"2020-11-20 19:35:29.180389+00:00\",\n \"date_revoked\": \"\",\n \"date_expired\": \"\",\n \"status\": \"active\",\n \"call_count\": 197,\n \"last_call\": \"2020-11-20 19:35:29.179258+00:00\",\n \"last_auth\": \"S\",\n \"last_used\": \"2020-11-20 19:35:29.179548+00:00\",\n \"last_method\": \"unknown\",\n \"last_route\": \"unknown\"\n}"
}
]
}