Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Req
oleobject loo_JsonParam1
oleobject loo_Resp
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Req = create oleobject
// Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_JsonParam1 = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JsonParam1.ConnectToNewObject("Chilkat.JsonObject")
loo_Req.AddParam("assertion",loo_JsonParam1.Emit())
loo_Req.AddParam("grant_type","urn:ietf:params:oauth:grant-type:jwt-bearer")
loo_Req.AddHeader("Authorization","Basic {{encodedKeys}}")
loo_Resp = loo_Http.PostUrlEncoded("https://{{hostenv}}/oauth/token",loo_Req)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
destroy loo_JsonParam1
return
end if
Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp
destroy loo_Http
destroy loo_Req
destroy loo_JsonParam1
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);"
]
}
}
],
"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": [
]
}