Back to Collection Items
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = Server.CreateObject("Chilkat.Http")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.HttpRequest")
set req = Server.CreateObject("Chilkat.HttpRequest")
req.AddParam "grant_type","client_credentials"
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam2 = Server.CreateObject("Chilkat.JsonObject")
req.AddParam "client_id",jsonParam2.Emit()
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam3 = Server.CreateObject("Chilkat.JsonObject")
req.AddParam "client_secret",jsonParam3.Emit()
req.AddParam "scope","pc pcapi"
' resp is a Chilkat.HttpResponse
Set resp = http.PostUrlEncoded("https://domain.com/",req)
If (http.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( resp.StatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
%>
</body>
</html>
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": [
]
}