Chilkat Online Tools

DataFlex / Bond APIs / Get Auth Token

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    Variant vDate_created
    Handle hoDate_created
    Variant vDate_updated
    Handle hoDate_updated
    Variant vDate_revoked
    Handle hoDate_revoked
    Variant vDate_expired
    Handle hoDate_expired
    String sIdentity
    String sKey_name
    String sRole_id
    String sRole_name
    String sOrg_id
    String sGrantor
    String sGrantee
    String sStatus
    Integer iCall_count
    String sLast_call
    String sLast_auth
    String sLast_used
    String sLast_method
    String sLast_route
    String sTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "Authorization" "{{authorization}}"
    Send ComSetRequestHeader To hoHttp "Identity" "{{identity}}"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://{{environment}}.bond.tech/api/v0/auth/key/{{identity}}" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

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

    Get Create (RefClass(cComChilkatDtObj)) To hoDate_created
    If (Not(IsComObjectCreated(hoDate_created))) Begin
        Send CreateComObject of hoDate_created
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoDate_updated
    If (Not(IsComObjectCreated(hoDate_updated))) Begin
        Send CreateComObject of hoDate_updated
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoDate_revoked
    If (Not(IsComObjectCreated(hoDate_revoked))) Begin
        Send CreateComObject of hoDate_revoked
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoDate_expired
    If (Not(IsComObjectCreated(hoDate_expired))) Begin
        Send CreateComObject of hoDate_expired
    End

    Get ComStringOf Of hoJResp "identity" To sIdentity
    Get ComStringOf Of hoJResp "key_name" To sKey_name
    Get ComStringOf Of hoJResp "role_id" To sRole_id
    Get ComStringOf Of hoJResp "role_name" To sRole_name
    Get ComStringOf Of hoJResp "org_id" To sOrg_id
    Get ComStringOf Of hoJResp "grantor" To sGrantor
    Get ComStringOf Of hoJResp "grantee" To sGrantee
    Get pvComObject of hoDate_created to vDate_created
    Get ComDtOf Of hoJResp "date_created" False vDate_created To iSuccess
    Get pvComObject of hoDate_updated to vDate_updated
    Get ComDtOf Of hoJResp "date_updated" False vDate_updated To iSuccess
    Get pvComObject of hoDate_revoked to vDate_revoked
    Get ComDtOf Of hoJResp "date_revoked" False vDate_revoked To iSuccess
    Get pvComObject of hoDate_expired to vDate_expired
    Get ComDtOf Of hoJResp "date_expired" False vDate_expired To iSuccess
    Get ComStringOf Of hoJResp "status" To sStatus
    Get ComIntOf Of hoJResp "call_count" To iCall_count
    Get ComStringOf Of hoJResp "last_call" To sLast_call
    Get ComStringOf Of hoJResp "last_auth" To sLast_auth
    Get ComStringOf Of hoJResp "last_used" To sLast_used
    Get ComStringOf Of hoJResp "last_method" To sLast_method
    Get ComStringOf Of hoJResp "last_route" To sLast_route


End_Procedure

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}"
    }
  ]
}