Chilkat Online Tools

Xojo / Salesforce Platform APIs / ID Token

Back to Collection Items

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

Dim http As New Chilkat.Http
Dim success As Boolean

http.SetRequestHeader "Content-Type","application/json"

Dim sbResponseBody As New Chilkat.StringBuilder
success = http.QuickGetSb("https://domain.com/id/{{_orgId}}/{{_userId}}",sbResponseBody)
If (success = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = http.LastStatus
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(http.LastHeader)
    System.DebugLog("Failed.")
    Return
End If

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

Dim id As String
id = jResp.StringOf("id")
Dim asserted_user As Boolean
asserted_user = jResp.BoolOf("asserted_user")
Dim user_id As String
user_id = jResp.StringOf("user_id")
Dim organization_id As String
organization_id = jResp.StringOf("organization_id")
Dim username As String
username = jResp.StringOf("username")
Dim nick_name As String
nick_name = jResp.StringOf("nick_name")
Dim display_name As String
display_name = jResp.StringOf("display_name")
Dim email As String
email = jResp.StringOf("email")
Dim email_verified As Boolean
email_verified = jResp.BoolOf("email_verified")
Dim first_name As String
first_name = jResp.StringOf("first_name")
Dim last_name As String
last_name = jResp.StringOf("last_name")
Dim timezone As String
timezone = jResp.StringOf("timezone")
Dim Picture As String
Picture = jResp.StringOf("photos.picture")
Dim Thumbnail As String
Thumbnail = jResp.StringOf("photos.thumbnail")
Dim addr_street As String
addr_street = jResp.StringOf("addr_street")
Dim addr_city As String
addr_city = jResp.StringOf("addr_city")
Dim addr_state As String
addr_state = jResp.StringOf("addr_state")
Dim addr_country As String
addr_country = jResp.StringOf("addr_country")
Dim addr_zip As String
addr_zip = jResp.StringOf("addr_zip")
Dim mobile_phone As String
mobile_phone = jResp.StringOf("mobile_phone")
Dim mobile_phone_verified As Boolean
mobile_phone_verified = jResp.BoolOf("mobile_phone_verified")
Dim is_lightning_login_user As Boolean
is_lightning_login_user = jResp.BoolOf("is_lightning_login_user")
Dim Created_date As String
Created_date = jResp.StringOf("status.created_date")
Dim Body As String
Body = jResp.StringOf("status.body")
Dim Enterprise As String
Enterprise = jResp.StringOf("urls.enterprise")
Dim Metadata As String
Metadata = jResp.StringOf("urls.metadata")
Dim Partner As String
Partner = jResp.StringOf("urls.partner")
Dim v_Rest As String
v_Rest = jResp.StringOf("urls.rest")
Dim Sobjects As String
Sobjects = jResp.StringOf("urls.sobjects")
Dim Search As String
Search = jResp.StringOf("urls.search")
Dim Query As String
Query = jResp.StringOf("urls.query")
Dim Recent As String
Recent = jResp.StringOf("urls.recent")
Dim Tooling_soap As String
Tooling_soap = jResp.StringOf("urls.tooling_soap")
Dim Tooling_rest As String
Tooling_rest = jResp.StringOf("urls.tooling_rest")
Dim Profile As String
Profile = jResp.StringOf("urls.profile")
Dim Feeds As String
Feeds = jResp.StringOf("urls.feeds")
Dim Groups As String
Groups = jResp.StringOf("urls.groups")
Dim Users As String
Users = jResp.StringOf("urls.users")
Dim Feed_items As String
Feed_items = jResp.StringOf("urls.feed_items")
Dim Feed_elements As String
Feed_elements = jResp.StringOf("urls.feed_elements")
Dim Custom_domain As String
Custom_domain = jResp.StringOf("urls.custom_domain")
Dim active As Boolean
active = jResp.BoolOf("active")
Dim user_type As String
user_type = jResp.StringOf("user_type")
Dim language As String
language = jResp.StringOf("language")
Dim locale As String
locale = jResp.StringOf("locale")
Dim utcOffset As Int32
utcOffset = jResp.IntOf("utcOffset")
Dim last_modified_date As String
last_modified_date = jResp.StringOf("last_modified_date")
Dim is_app_installed As Boolean
is_app_installed = jResp.BoolOf("is_app_installed")

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