Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *id;
BOOL asserted_user;
const wchar_t *user_id;
const wchar_t *organization_id;
const wchar_t *username;
const wchar_t *nick_name;
const wchar_t *display_name;
const wchar_t *email;
BOOL email_verified;
const wchar_t *first_name;
const wchar_t *last_name;
const wchar_t *timezone;
const wchar_t *Picture;
const wchar_t *Thumbnail;
const wchar_t *addr_street;
const wchar_t *addr_city;
const wchar_t *addr_state;
const wchar_t *addr_country;
const wchar_t *addr_zip;
const wchar_t *mobile_phone;
BOOL mobile_phone_verified;
BOOL is_lightning_login_user;
const wchar_t *Created_date;
const wchar_t *Body;
const wchar_t *Enterprise;
const wchar_t *Metadata;
const wchar_t *Partner;
const wchar_t *v_Rest;
const wchar_t *Sobjects;
const wchar_t *Search;
const wchar_t *Query;
const wchar_t *Recent;
const wchar_t *Tooling_soap;
const wchar_t *Tooling_rest;
const wchar_t *Profile;
const wchar_t *Feeds;
const wchar_t *Groups;
const wchar_t *Users;
const wchar_t *Feed_items;
const wchar_t *Feed_elements;
const wchar_t *Custom_domain;
BOOL active;
const wchar_t *user_type;
const wchar_t *language;
const wchar_t *locale;
int utcOffset;
const wchar_t *last_modified_date;
BOOL is_app_installed;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://domain.com/id/{{_orgId}}/{{_userId}}",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// 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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
id = CkJsonObjectW_stringOf(jResp,L"id");
asserted_user = CkJsonObjectW_BoolOf(jResp,L"asserted_user");
user_id = CkJsonObjectW_stringOf(jResp,L"user_id");
organization_id = CkJsonObjectW_stringOf(jResp,L"organization_id");
username = CkJsonObjectW_stringOf(jResp,L"username");
nick_name = CkJsonObjectW_stringOf(jResp,L"nick_name");
display_name = CkJsonObjectW_stringOf(jResp,L"display_name");
email = CkJsonObjectW_stringOf(jResp,L"email");
email_verified = CkJsonObjectW_BoolOf(jResp,L"email_verified");
first_name = CkJsonObjectW_stringOf(jResp,L"first_name");
last_name = CkJsonObjectW_stringOf(jResp,L"last_name");
timezone = CkJsonObjectW_stringOf(jResp,L"timezone");
Picture = CkJsonObjectW_stringOf(jResp,L"photos.picture");
Thumbnail = CkJsonObjectW_stringOf(jResp,L"photos.thumbnail");
addr_street = CkJsonObjectW_stringOf(jResp,L"addr_street");
addr_city = CkJsonObjectW_stringOf(jResp,L"addr_city");
addr_state = CkJsonObjectW_stringOf(jResp,L"addr_state");
addr_country = CkJsonObjectW_stringOf(jResp,L"addr_country");
addr_zip = CkJsonObjectW_stringOf(jResp,L"addr_zip");
mobile_phone = CkJsonObjectW_stringOf(jResp,L"mobile_phone");
mobile_phone_verified = CkJsonObjectW_BoolOf(jResp,L"mobile_phone_verified");
is_lightning_login_user = CkJsonObjectW_BoolOf(jResp,L"is_lightning_login_user");
Created_date = CkJsonObjectW_stringOf(jResp,L"status.created_date");
Body = CkJsonObjectW_stringOf(jResp,L"status.body");
Enterprise = CkJsonObjectW_stringOf(jResp,L"urls.enterprise");
Metadata = CkJsonObjectW_stringOf(jResp,L"urls.metadata");
Partner = CkJsonObjectW_stringOf(jResp,L"urls.partner");
v_Rest = CkJsonObjectW_stringOf(jResp,L"urls.rest");
Sobjects = CkJsonObjectW_stringOf(jResp,L"urls.sobjects");
Search = CkJsonObjectW_stringOf(jResp,L"urls.search");
Query = CkJsonObjectW_stringOf(jResp,L"urls.query");
Recent = CkJsonObjectW_stringOf(jResp,L"urls.recent");
Tooling_soap = CkJsonObjectW_stringOf(jResp,L"urls.tooling_soap");
Tooling_rest = CkJsonObjectW_stringOf(jResp,L"urls.tooling_rest");
Profile = CkJsonObjectW_stringOf(jResp,L"urls.profile");
Feeds = CkJsonObjectW_stringOf(jResp,L"urls.feeds");
Groups = CkJsonObjectW_stringOf(jResp,L"urls.groups");
Users = CkJsonObjectW_stringOf(jResp,L"urls.users");
Feed_items = CkJsonObjectW_stringOf(jResp,L"urls.feed_items");
Feed_elements = CkJsonObjectW_stringOf(jResp,L"urls.feed_elements");
Custom_domain = CkJsonObjectW_stringOf(jResp,L"urls.custom_domain");
active = CkJsonObjectW_BoolOf(jResp,L"active");
user_type = CkJsonObjectW_stringOf(jResp,L"user_type");
language = CkJsonObjectW_stringOf(jResp,L"language");
locale = CkJsonObjectW_stringOf(jResp,L"locale");
utcOffset = CkJsonObjectW_IntOf(jResp,L"utcOffset");
last_modified_date = CkJsonObjectW_stringOf(jResp,L"last_modified_date");
is_app_installed = CkJsonObjectW_BoolOf(jResp,L"is_app_installed");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(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}"
}
]
}