Chilkat Online Tools

Foxpro / Salesforce Platform APIs / ID Token

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcId
LOCAL lnAsserted_user
LOCAL lcUser_id
LOCAL lcOrganization_id
LOCAL lcUsername
LOCAL lcNick_name
LOCAL lcDisplay_name
LOCAL lcEmail
LOCAL lnEmail_verified
LOCAL lcFirst_name
LOCAL lcLast_name
LOCAL lcTimezone
LOCAL lcPicture
LOCAL lcThumbnail
LOCAL lcAddr_street
LOCAL lcAddr_city
LOCAL lcAddr_state
LOCAL lcAddr_country
LOCAL lcAddr_zip
LOCAL lcMobile_phone
LOCAL lnMobile_phone_verified
LOCAL lnIs_lightning_login_user
LOCAL lcCreated_date
LOCAL lcBody
LOCAL lcEnterprise
LOCAL lcMetadata
LOCAL lcPartner
LOCAL lcV_Rest
LOCAL lcSobjects
LOCAL lcSearch
LOCAL lcQuery
LOCAL lcRecent
LOCAL lcTooling_soap
LOCAL lcTooling_rest
LOCAL lcProfile
LOCAL lcFeeds
LOCAL lcGroups
LOCAL lcUsers
LOCAL lcFeed_items
LOCAL lcFeed_elements
LOCAL lcCustom_domain
LOCAL lnActive
LOCAL lcUser_type
LOCAL lcLanguage
LOCAL lcLocale
LOCAL lnUtcOffset
LOCAL lcLast_modified_date
LOCAL lnIs_app_installed

* 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")

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://domain.com/id/{{_orgId}}/{{_userId}}",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)

* {
*   "id": "https://login.salesforce.com/id/00D.../005...",
*   "asserted_user": true,
*   "user_id": "005...",
*   "organization_id": "00D...",
*   "username": "<username>",
*   "nick_name": "<nickname>",
*   "display_name": "<display_name>",
*   "email": "<email>",
*   "email_verified": true,
*   "first_name": "<firstname>",
*   "last_name": "<lastname>",
*   "timezone": "Europe/Paris",
*   "photos": {
*     "picture": "https://<my_domain>/profilephoto/005/F",
*     "thumbnail": "https://<my_domain>/profilephoto/005/T"
*   },
*   "addr_street": null,
*   "addr_city": null,
*   "addr_state": null,
*   "addr_country": "FR",
*   "addr_zip": null,
*   "mobile_phone": null,
*   "mobile_phone_verified": false,
*   "is_lightning_login_user": false,
*   "status": {
*     "created_date": null,
*     "body": null
*   },
*   "urls": {
*     "enterprise": "https://<my_domain>/services/Soap/c/{version}/00D...",
*     "metadata": "https://<my_domain>/services/Soap/m/{version}/00D...",
*     "partner": "https://<my_domain>/services/Soap/u/{version}/00D...",
*     "rest": "https://<my_domain>/services/data/v{version}/",
*     "sobjects": "https://<my_domain>/services/data/v{version}/sobjects/",
*     "search": "https://<my_domain>/services/data/v{version}/search/",
*     "query": "https://<my_domain>/services/data/v{version}/query/",
*     "recent": "https://<my_domain>/services/data/v{version}/recent/",
*     "tooling_soap": "https://<my_domain>/services/Soap/T/{version}/00D...",
*     "tooling_rest": "https://<my_domain>/services/data/v{version}/tooling/",
*     "profile": "https://<my_domain>/0052o00000DOJ1PAAX",
*     "feeds": "https://<my_domain>/services/data/v{version}/chatter/feeds",
*     "groups": "https://<my_domain>/services/data/v{version}/chatter/groups",
*     "users": "https://<my_domain>/services/data/v{version}/chatter/users",
*     "feed_items": "https://<my_domain>/services/data/v{version}/chatter/feed-items",
*     "feed_elements": "https://<my_domain>/services/data/v{version}/chatter/feed-elements",
*     "custom_domain": "https://<my_domain>"
*   },
*   "active": true,
*   "user_type": "STANDARD",
*   "language": "en_US",
*   "locale": "fr_FR_EURO",
*   "utcOffset": 3600000,
*   "last_modified_date": "<date_time>",
*   "is_app_installed": true
* }

* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

lcId = loJResp.StringOf("id")
lnAsserted_user = loJResp.BoolOf("asserted_user")
lcUser_id = loJResp.StringOf("user_id")
lcOrganization_id = loJResp.StringOf("organization_id")
lcUsername = loJResp.StringOf("username")
lcNick_name = loJResp.StringOf("nick_name")
lcDisplay_name = loJResp.StringOf("display_name")
lcEmail = loJResp.StringOf("email")
lnEmail_verified = loJResp.BoolOf("email_verified")
lcFirst_name = loJResp.StringOf("first_name")
lcLast_name = loJResp.StringOf("last_name")
lcTimezone = loJResp.StringOf("timezone")
lcPicture = loJResp.StringOf("photos.picture")
lcThumbnail = loJResp.StringOf("photos.thumbnail")
lcAddr_street = loJResp.StringOf("addr_street")
lcAddr_city = loJResp.StringOf("addr_city")
lcAddr_state = loJResp.StringOf("addr_state")
lcAddr_country = loJResp.StringOf("addr_country")
lcAddr_zip = loJResp.StringOf("addr_zip")
lcMobile_phone = loJResp.StringOf("mobile_phone")
lnMobile_phone_verified = loJResp.BoolOf("mobile_phone_verified")
lnIs_lightning_login_user = loJResp.BoolOf("is_lightning_login_user")
lcCreated_date = loJResp.StringOf("status.created_date")
lcBody = loJResp.StringOf("status.body")
lcEnterprise = loJResp.StringOf("urls.enterprise")
lcMetadata = loJResp.StringOf("urls.metadata")
lcPartner = loJResp.StringOf("urls.partner")
lcV_Rest = loJResp.StringOf("urls.rest")
lcSobjects = loJResp.StringOf("urls.sobjects")
lcSearch = loJResp.StringOf("urls.search")
lcQuery = loJResp.StringOf("urls.query")
lcRecent = loJResp.StringOf("urls.recent")
lcTooling_soap = loJResp.StringOf("urls.tooling_soap")
lcTooling_rest = loJResp.StringOf("urls.tooling_rest")
lcProfile = loJResp.StringOf("urls.profile")
lcFeeds = loJResp.StringOf("urls.feeds")
lcGroups = loJResp.StringOf("urls.groups")
lcUsers = loJResp.StringOf("urls.users")
lcFeed_items = loJResp.StringOf("urls.feed_items")
lcFeed_elements = loJResp.StringOf("urls.feed_elements")
lcCustom_domain = loJResp.StringOf("urls.custom_domain")
lnActive = loJResp.BoolOf("active")
lcUser_type = loJResp.StringOf("user_type")
lcLanguage = loJResp.StringOf("language")
lcLocale = loJResp.StringOf("locale")
lnUtcOffset = loJResp.IntOf("utcOffset")
lcLast_modified_date = loJResp.StringOf("last_modified_date")
lnIs_app_installed = loJResp.BoolOf("is_app_installed")

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl -X GET
	-H "Content-Type: application/json"
https://domain.com/id/{{_orgId}}/{{_userId}}

Postman Collection Item JSON

{
  "name": "ID Token",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{_endpoint}}/id/{{_orgId}}/{{_userId}}",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "id",
        "{{_orgId}}",
        "{{_userId}}"
      ]
    }
  },
  "response": [
    {
      "name": "Successful ID Token",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{_endpoint}}/id/{{_orgId}}/{{_userId}}",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "id",
            "{{_orgId}}",
            "{{_userId}}"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Thu, 16 Nov 2023 15:56:09 GMT"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000; includeSubDomains"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "X-Robots-Tag",
          "value": "none"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache,must-revalidate,max-age=0,no-store,private"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=UTF-8"
        },
        {
          "key": "Vary",
          "value": "Accept-Encoding"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"id\": \"https://login.salesforce.com/id/00D.../005...\",\n    \"asserted_user\": true,\n    \"user_id\": \"005...\",\n    \"organization_id\": \"00D...\",\n    \"username\": \"<username>\",\n    \"nick_name\": \"<nickname>\",\n    \"display_name\": \"<display_name>\",\n    \"email\": \"<email>\",\n    \"email_verified\": true,\n    \"first_name\": \"<firstname>\",\n    \"last_name\": \"<lastname>\",\n    \"timezone\": \"Europe/Paris\",\n    \"photos\": {\n        \"picture\": \"https://<my_domain>/profilephoto/005/F\",\n        \"thumbnail\": \"https://<my_domain>/profilephoto/005/T\"\n    },\n    \"addr_street\": null,\n    \"addr_city\": null,\n    \"addr_state\": null,\n    \"addr_country\": \"FR\",\n    \"addr_zip\": null,\n    \"mobile_phone\": null,\n    \"mobile_phone_verified\": false,\n    \"is_lightning_login_user\": false,\n    \"status\": {\n        \"created_date\": null,\n        \"body\": null\n    },\n    \"urls\": {\n        \"enterprise\": \"https://<my_domain>/services/Soap/c/{version}/00D...\",\n        \"metadata\": \"https://<my_domain>/services/Soap/m/{version}/00D...\",\n        \"partner\": \"https://<my_domain>/services/Soap/u/{version}/00D...\",\n        \"rest\": \"https://<my_domain>/services/data/v{version}/\",\n        \"sobjects\": \"https://<my_domain>/services/data/v{version}/sobjects/\",\n        \"search\": \"https://<my_domain>/services/data/v{version}/search/\",\n        \"query\": \"https://<my_domain>/services/data/v{version}/query/\",\n        \"recent\": \"https://<my_domain>/services/data/v{version}/recent/\",\n        \"tooling_soap\": \"https://<my_domain>/services/Soap/T/{version}/00D...\",\n        \"tooling_rest\": \"https://<my_domain>/services/data/v{version}/tooling/\",\n        \"profile\": \"https://<my_domain>/0052o00000DOJ1PAAX\",\n        \"feeds\": \"https://<my_domain>/services/data/v{version}/chatter/feeds\",\n        \"groups\": \"https://<my_domain>/services/data/v{version}/chatter/groups\",\n        \"users\": \"https://<my_domain>/services/data/v{version}/chatter/users\",\n        \"feed_items\": \"https://<my_domain>/services/data/v{version}/chatter/feed-items\",\n        \"feed_elements\": \"https://<my_domain>/services/data/v{version}/chatter/feed-elements\",\n        \"custom_domain\": \"https://<my_domain>\"\n    },\n    \"active\": true,\n    \"user_type\": \"STANDARD\",\n    \"language\": \"en_US\",\n    \"locale\": \"fr_FR_EURO\",\n    \"utcOffset\": 3600000,\n    \"last_modified_date\": \"<date_time>\",\n    \"is_app_installed\": true\n}"
    }
  ]
}