Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' 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 = CreateObject("Chilkat.Http")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.HttpRequest")
set req = 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 = 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 = CreateObject("Chilkat.JsonObject")
req.AddParam "client_secret",jsonParam3.Emit()
req.AddHeader "presharedkey","C68FEC13-FE34-4839-89F9-ADB0D678CFE0"
req.AddHeader "posmodelframework","1"
req.AddHeader "posserial","Test_SerialNo1"
req.AddHeader "pososversion","IOS"
' resp is a Chilkat.HttpResponse
Set resp = http.PostUrlEncoded("https://domain.com/connect/token",req)
If (http.LastMethodSuccess = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)
outFile.Close
Curl Command
curl -X POST
-H "posserial: Test_SerialNo1"
-H "pososversion: IOS"
-H "posmodelframework: 1"
-H "presharedkey: C68FEC13-FE34-4839-89F9-ADB0D678CFE0"
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'client_id={{clientId}}'
--data-urlencode 'client_secret={{clientSecret}}'
https://domain.com/connect/token
Postman Collection Item JSON
{
"name": "1. Authenticate POS",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var json = pm.response.json()\r",
"var accesstoken=json.access_token\r",
"pm.environment.set(\"generatedAccessToken\",accesstoken);\r",
"\r",
"pm.test(\"Status code is 200\", function () {\r",
" pm.response.to.have.status(200);\r",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "posserial",
"value": "Test_SerialNo1",
"type": "text"
},
{
"key": "pososversion",
"value": "IOS",
"type": "text"
},
{
"key": "posmodelframework",
"value": "1",
"type": "text",
"disabled": true
},
{
"key": "presharedkey",
"value": "C68FEC13-FE34-4839-89F9-ADB0D678CFE0",
"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"
}
]
},
"url": {
"raw": "{{idSrvBaseUrl}}/connect/token",
"host": [
"{{idSrvBaseUrl}}"
],
"path": [
"connect",
"token"
]
}
},
"response": [
]
}