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.
set http = Server.CreateObject("Chilkat_9_5_0.Http")
set req = Server.CreateObject("Chilkat_9_5_0.HttpRequest")
req.AddParam "grant_type","client_credentials"
set jsonParam2 = Server.CreateObject("Chilkat_9_5_0.JsonObject")
req.AddParam "client_id",jsonParam2.Emit()
set jsonParam3 = Server.CreateObject("Chilkat_9_5_0.JsonObject")
req.AddParam "client_secret",jsonParam3.Emit()
req.AddParam "scope","InvoicingAPI"
' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.PostUrlEncoded("https://domain.com/connect/token",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={{clientId}}'
--data-urlencode 'client_secret={{clientSecret}}'
--data-urlencode 'scope=InvoicingAPI'
https://domain.com/connect/token
Postman Collection Item JSON
{
"name": "1. Login as Taxpayer System",
"event": [
{
"listen": "test",
"script": {
"exec": [
"\r",
"pm.test(\"Status code is 200\", function () {\r",
"var jsonData = JSON.parse(responseBody);\r",
"pm.environment.set(\"generatedAccessToken\", jsonData.access_token);\r",
"});\r",
"\r",
"\r",
"\r",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
},
{
"key": "client_id",
"value": "{{clientId}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{clientSecret}}",
"type": "text"
},
{
"key": "scope",
"value": "InvoicingAPI",
"type": "text"
}
]
},
"url": {
"raw": "{{idSrvBaseUrl}}/connect/token",
"host": [
"{{idSrvBaseUrl}}"
],
"path": [
"connect",
"token"
]
}
},
"response": [
]
}