Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
var req = new chilkat.HttpRequest();
req.AddParam("grant_type","client_credentials");
var jsonParam2 = new chilkat.JsonObject();
req.AddParam("client_id",jsonParam2.Emit());
var jsonParam3 = new chilkat.JsonObject();
req.AddParam("client_secret",jsonParam3.Emit());
req.AddParam("scope","pc pcapi");
// resp: HttpResponse
var resp = http.PostUrlEncoded("https://domain.com/",req);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
console.log(resp.StatusCode);
console.log(resp.BodyStr);
}
chilkatExample();
Curl Command
curl -X POST
-H "Content-Type: application/x-www-form-urlencoded"
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'client_id={{partner_client_id}}'
--data-urlencode 'client_secret={{partner_client_secret}}'
--data-urlencode 'scope=pc pcapi'
https://domain.com/
Postman Collection Item JSON
{
"name": "[Partner] Create Partner Authentication Token",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Extract oAuth Token from response body",
"var jsonData = JSON.parse(responseBody);",
"var partnerToken = jsonData.access_token;",
"",
"// Set to an environment variable",
"postman.setEnvironmentVariable(\"partner_token\", partnerToken);"
]
}
}
],
"_postman_id": "6f420d0f-ef65-40dc-a870-e21ff2522ccf",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
},
{
"key": "client_id",
"value": "{{partner_client_id}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{partner_client_secret}}",
"type": "text"
},
{
"key": "scope",
"value": "pc pcapi",
"type": "text"
}
]
},
"url": "{{api_host}}/oauth2/v1/token"
},
"response": [
]
}