Chilkat Online Tools

PowerBuilder / Salesforce Platform APIs / ID Token

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
integer li_Asserted_user
string ls_User_id
string ls_Organization_id
string ls_Username
string ls_Nick_name
string ls_Display_name
string ls_Email
integer li_Email_verified
string ls_First_name
string ls_Last_name
string ls_Timezone
string ls_Picture
string ls_Thumbnail
string ls_Addr_street
string ls_Addr_city
string ls_Addr_state
string ls_Addr_country
string ls_Addr_zip
string ls_Mobile_phone
integer li_Mobile_phone_verified
integer li_Is_lightning_login_user
string ls_Created_date
string ls_Body
string ls_Enterprise
string ls_Metadata
string ls_Partner
string ls_V_Rest
string ls_Sobjects
string ls_Search
string ls_Query
string ls_Recent
string ls_Tooling_soap
string ls_Tooling_rest
string ls_Profile
string ls_Feeds
string ls_Groups
string ls_Users
string ls_Feed_items
string ls_Feed_elements
string ls_Custom_domain
integer li_Active
string ls_User_type
string ls_Language
string ls_Locale
integer li_UtcOffset
string ls_Last_modified_date
integer li_Is_app_installed

// 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_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://domain.com/id/{{_orgId}}/{{_userId}}",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)

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

ls_Id = loo_JResp.StringOf("id")
li_Asserted_user = loo_JResp.BoolOf("asserted_user")
ls_User_id = loo_JResp.StringOf("user_id")
ls_Organization_id = loo_JResp.StringOf("organization_id")
ls_Username = loo_JResp.StringOf("username")
ls_Nick_name = loo_JResp.StringOf("nick_name")
ls_Display_name = loo_JResp.StringOf("display_name")
ls_Email = loo_JResp.StringOf("email")
li_Email_verified = loo_JResp.BoolOf("email_verified")
ls_First_name = loo_JResp.StringOf("first_name")
ls_Last_name = loo_JResp.StringOf("last_name")
ls_Timezone = loo_JResp.StringOf("timezone")
ls_Picture = loo_JResp.StringOf("photos.picture")
ls_Thumbnail = loo_JResp.StringOf("photos.thumbnail")
ls_Addr_street = loo_JResp.StringOf("addr_street")
ls_Addr_city = loo_JResp.StringOf("addr_city")
ls_Addr_state = loo_JResp.StringOf("addr_state")
ls_Addr_country = loo_JResp.StringOf("addr_country")
ls_Addr_zip = loo_JResp.StringOf("addr_zip")
ls_Mobile_phone = loo_JResp.StringOf("mobile_phone")
li_Mobile_phone_verified = loo_JResp.BoolOf("mobile_phone_verified")
li_Is_lightning_login_user = loo_JResp.BoolOf("is_lightning_login_user")
ls_Created_date = loo_JResp.StringOf("status.created_date")
ls_Body = loo_JResp.StringOf("status.body")
ls_Enterprise = loo_JResp.StringOf("urls.enterprise")
ls_Metadata = loo_JResp.StringOf("urls.metadata")
ls_Partner = loo_JResp.StringOf("urls.partner")
ls_V_Rest = loo_JResp.StringOf("urls.rest")
ls_Sobjects = loo_JResp.StringOf("urls.sobjects")
ls_Search = loo_JResp.StringOf("urls.search")
ls_Query = loo_JResp.StringOf("urls.query")
ls_Recent = loo_JResp.StringOf("urls.recent")
ls_Tooling_soap = loo_JResp.StringOf("urls.tooling_soap")
ls_Tooling_rest = loo_JResp.StringOf("urls.tooling_rest")
ls_Profile = loo_JResp.StringOf("urls.profile")
ls_Feeds = loo_JResp.StringOf("urls.feeds")
ls_Groups = loo_JResp.StringOf("urls.groups")
ls_Users = loo_JResp.StringOf("urls.users")
ls_Feed_items = loo_JResp.StringOf("urls.feed_items")
ls_Feed_elements = loo_JResp.StringOf("urls.feed_elements")
ls_Custom_domain = loo_JResp.StringOf("urls.custom_domain")
li_Active = loo_JResp.BoolOf("active")
ls_User_type = loo_JResp.StringOf("user_type")
ls_Language = loo_JResp.StringOf("language")
ls_Locale = loo_JResp.StringOf("locale")
li_UtcOffset = loo_JResp.IntOf("utcOffset")
ls_Last_modified_date = loo_JResp.StringOf("last_modified_date")
li_Is_app_installed = loo_JResp.BoolOf("is_app_installed")


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

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