Back to Collection Items
var
http: HCkHttp;
success: Boolean;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
v_sub: PWideChar;
user_id: PWideChar;
organization_id: PWideChar;
preferred_username: PWideChar;
nickname: PWideChar;
name: PWideChar;
email: PWideChar;
email_verified: Boolean;
given_name: PWideChar;
family_name: PWideChar;
zoneinfo: PWideChar;
Picture: PWideChar;
Thumbnail: PWideChar;
profile: PWideChar;
picture: PWideChar;
Country: PWideChar;
is_salesforce_integration_user: Boolean;
Enterprise: PWideChar;
Metadata: PWideChar;
Partner: PWideChar;
v_Rest: PWideChar;
Sobjects: PWideChar;
Search: PWideChar;
Query: PWideChar;
Recent: PWideChar;
Tooling_soap: PWideChar;
Tooling_rest: PWideChar;
Profile: PWideChar;
Feeds: PWideChar;
Groups: PWideChar;
Users: PWideChar;
Feed_items: PWideChar;
Feed_elements: PWideChar;
Custom_domain: PWideChar;
active: Boolean;
user_type: PWideChar;
language: PWideChar;
locale: PWideChar;
utcOffset: Integer;
updated_at: PWideChar;
is_app_installed: Boolean;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
CkHttp_SetRequestHeader(http,'Content-Type','application/json');
sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://login.salesforce.com{{site}}/services/oauth2/userinfo',sbResponseBody);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttp__lastHeader(http));
Memo1.Lines.Add('Failed.');
Exit;
end;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "sub": "https://login.salesforce.com/id/00D.../005...",
// "user_id": "005...",
// "organization_id": "00D...",
// "preferred_username": "<username>",
// "nickname": "<nickname>",
// "name": "<name>",
// "email": "<email>",
// "email_verified": true,
// "given_name": "<name>",
// "family_name": "<name>",
// "zoneinfo": "Europe/Paris",
// "photos": {
// "picture": "https://<file_domain>/profilephoto/005/F",
// "thumbnail": "https://<file_domain>/profilephoto/005/T"
// },
// "profile": "https://<my_domain>/005",
// "picture": "https://<file_domain>/profilephoto/005/F",
// "address": {
// "country": "FR"
// },
// "is_salesforce_integration_user": false,
// "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,
// "updated_at": "<datetime>",
// "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
v_sub := CkJsonObject__stringOf(jResp,'sub');
user_id := CkJsonObject__stringOf(jResp,'user_id');
organization_id := CkJsonObject__stringOf(jResp,'organization_id');
preferred_username := CkJsonObject__stringOf(jResp,'preferred_username');
nickname := CkJsonObject__stringOf(jResp,'nickname');
name := CkJsonObject__stringOf(jResp,'name');
email := CkJsonObject__stringOf(jResp,'email');
email_verified := CkJsonObject_BoolOf(jResp,'email_verified');
given_name := CkJsonObject__stringOf(jResp,'given_name');
family_name := CkJsonObject__stringOf(jResp,'family_name');
zoneinfo := CkJsonObject__stringOf(jResp,'zoneinfo');
Picture := CkJsonObject__stringOf(jResp,'photos.picture');
Thumbnail := CkJsonObject__stringOf(jResp,'photos.thumbnail');
profile := CkJsonObject__stringOf(jResp,'profile');
picture := CkJsonObject__stringOf(jResp,'picture');
Country := CkJsonObject__stringOf(jResp,'address.country');
is_salesforce_integration_user := CkJsonObject_BoolOf(jResp,'is_salesforce_integration_user');
Enterprise := CkJsonObject__stringOf(jResp,'urls.enterprise');
Metadata := CkJsonObject__stringOf(jResp,'urls.metadata');
Partner := CkJsonObject__stringOf(jResp,'urls.partner');
v_Rest := CkJsonObject__stringOf(jResp,'urls.rest');
Sobjects := CkJsonObject__stringOf(jResp,'urls.sobjects');
Search := CkJsonObject__stringOf(jResp,'urls.search');
Query := CkJsonObject__stringOf(jResp,'urls.query');
Recent := CkJsonObject__stringOf(jResp,'urls.recent');
Tooling_soap := CkJsonObject__stringOf(jResp,'urls.tooling_soap');
Tooling_rest := CkJsonObject__stringOf(jResp,'urls.tooling_rest');
Profile := CkJsonObject__stringOf(jResp,'urls.profile');
Feeds := CkJsonObject__stringOf(jResp,'urls.feeds');
Groups := CkJsonObject__stringOf(jResp,'urls.groups');
Users := CkJsonObject__stringOf(jResp,'urls.users');
Feed_items := CkJsonObject__stringOf(jResp,'urls.feed_items');
Feed_elements := CkJsonObject__stringOf(jResp,'urls.feed_elements');
Custom_domain := CkJsonObject__stringOf(jResp,'urls.custom_domain');
active := CkJsonObject_BoolOf(jResp,'active');
user_type := CkJsonObject__stringOf(jResp,'user_type');
language := CkJsonObject__stringOf(jResp,'language');
locale := CkJsonObject__stringOf(jResp,'locale');
utcOffset := CkJsonObject_IntOf(jResp,'utcOffset');
updated_at := CkJsonObject__stringOf(jResp,'updated_at');
is_app_installed := CkJsonObject_BoolOf(jResp,'is_app_installed');
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
Curl Command
curl -X GET
-H "Content-Type: application/json"
https://login.salesforce.com{{site}}/services/oauth2/userinfo
Postman Collection Item JSON
{
"name": "User Info",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{url}}{{site}}/services/oauth2/userinfo",
"host": [
"{{url}}{{site}}"
],
"path": [
"services",
"oauth2",
"userinfo"
]
}
},
"response": [
{
"name": "Successful User Info",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{url}}{{site}}/services/oauth2/userinfo",
"host": [
"{{url}}{{site}}"
],
"path": [
"services",
"oauth2",
"userinfo"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Thu, 16 Nov 2023 15:35:50 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 \"sub\": \"https://login.salesforce.com/id/00D.../005...\",\n \"user_id\": \"005...\",\n \"organization_id\": \"00D...\",\n \"preferred_username\": \"<username>\",\n \"nickname\": \"<nickname>\",\n \"name\": \"<name>\",\n \"email\": \"<email>\",\n \"email_verified\": true,\n \"given_name\": \"<name>\",\n \"family_name\": \"<name>\",\n \"zoneinfo\": \"Europe/Paris\",\n \"photos\": {\n \"picture\": \"https://<file_domain>/profilephoto/005/F\",\n \"thumbnail\": \"https://<file_domain>/profilephoto/005/T\"\n },\n \"profile\": \"https://<my_domain>/005\",\n \"picture\": \"https://<file_domain>/profilephoto/005/F\",\n \"address\": {\n \"country\": \"FR\"\n },\n \"is_salesforce_integration_user\": false,\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 \"updated_at\": \"<datetime>\",\n \"is_app_installed\": true\n}"
}
]
}