Chilkat Online Tools

PowerBuilder / Bond APIs / Get Auth Token

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
oleobject loo_Date_created
oleobject loo_Date_updated
oleobject loo_Date_revoked
oleobject loo_Date_expired
string ls_Identity
string ls_Key_name
string ls_Role_id
string ls_Role_name
string ls_Org_id
string ls_Grantor
string ls_Grantee
string ls_Status
integer li_Call_count
string ls_Last_call
string ls_Last_auth
string ls_Last_used
string ls_Last_method
string ls_Last_route

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("Authorization","{{authorization}}")
loo_Http.SetRequestHeader("Identity","{{identity}}")

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://{{environment}}.bond.tech/api/v0/auth/key/{{identity}}",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// 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

loo_Date_created = create oleobject
// Use "Chilkat_9_5_0.DtObj" for versions of Chilkat < 10.0.0
li_rc = loo_Date_created.ConnectToNewObject("Chilkat.DtObj")

loo_Date_updated = create oleobject
// Use "Chilkat_9_5_0.DtObj" for versions of Chilkat < 10.0.0
li_rc = loo_Date_updated.ConnectToNewObject("Chilkat.DtObj")

loo_Date_revoked = create oleobject
// Use "Chilkat_9_5_0.DtObj" for versions of Chilkat < 10.0.0
li_rc = loo_Date_revoked.ConnectToNewObject("Chilkat.DtObj")

loo_Date_expired = create oleobject
// Use "Chilkat_9_5_0.DtObj" for versions of Chilkat < 10.0.0
li_rc = loo_Date_expired.ConnectToNewObject("Chilkat.DtObj")

ls_Identity = loo_JResp.StringOf("identity")
ls_Key_name = loo_JResp.StringOf("key_name")
ls_Role_id = loo_JResp.StringOf("role_id")
ls_Role_name = loo_JResp.StringOf("role_name")
ls_Org_id = loo_JResp.StringOf("org_id")
ls_Grantor = loo_JResp.StringOf("grantor")
ls_Grantee = loo_JResp.StringOf("grantee")
loo_JResp.DtOf("date_created",0,loo_Date_created)
loo_JResp.DtOf("date_updated",0,loo_Date_updated)
loo_JResp.DtOf("date_revoked",0,loo_Date_revoked)
loo_JResp.DtOf("date_expired",0,loo_Date_expired)
ls_Status = loo_JResp.StringOf("status")
li_Call_count = loo_JResp.IntOf("call_count")
ls_Last_call = loo_JResp.StringOf("last_call")
ls_Last_auth = loo_JResp.StringOf("last_auth")
ls_Last_used = loo_JResp.StringOf("last_used")
ls_Last_method = loo_JResp.StringOf("last_method")
ls_Last_route = loo_JResp.StringOf("last_route")


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
destroy loo_Date_created
destroy loo_Date_updated
destroy loo_Date_revoked
destroy loo_Date_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}"
    }
  ]
}