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")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam1 = CreateObject("Chilkat.JsonObject")
req.AddParam "assertion",jsonParam1.Emit()
req.AddParam "grant_type","urn:ietf:params:oauth:grant-type:jwt-bearer"
req.AddHeader "Authorization","Basic {{encodedKeys}}"
' resp is a Chilkat.HttpResponse
Set resp = http.PostUrlEncoded("https://{{hostenv}}/oauth/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 "Authorization: Basic {{encodedKeys}}"
--data-urlencode 'assertion={{assertionHere}}'
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer'
https://{{hostenv}}/oauth/token
Postman Collection Item JSON
{
"name": "02 JWT Access Token",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"accessToken\", jsonData.access_token);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"refreshToken\", jsonData.refresh_token);"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Basic {{encodedKeys}}"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "assertion",
"value": "{{assertionHere}}"
},
{
"key": "grant_type",
"value": "urn:ietf:params:oauth:grant-type:jwt-bearer"
}
]
},
"url": {
"raw": "https://{{hostenv}}/oauth/token",
"protocol": "https",
"host": [
"{{hostenv}}"
],
"path": [
"oauth",
"token"
]
}
},
"response": [
]
}