ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/x-www-form-urlencoded
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
new HttpRequest req;
new JsonObject jsonParam1;
call req.AddParam("assertion",jsonParam1.Emit());
call req.AddParam("grant_type","urn:ietf:params:oauth:grant-type:jwt-bearer");
call req.AddHeader("Authorization","Basic {{encodedKeys}}");
new HttpResponse resp;
req.HttpVerb = "POST";
req.ContentType = "application/x-www-form-urlencoded";
success = http.PostUrlEncoded("https://{{hostenv}}/oauth/token", req,resp);
if (success == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
---- end chilkat script ----
Back to Collection Items
load ./chilkat.dll
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
set req [new_CkHttpRequest]
set jsonParam1 [new_CkJsonObject]
CkHttpRequest_AddParam $req "assertion" [CkJsonObject_emit $jsonParam1]
CkHttpRequest_AddParam $req "grant_type" "urn:ietf:params:oauth:grant-type:jwt-bearer"
CkHttpRequest_AddHeader $req "Authorization" "Basic {{encodedKeys}}"
set resp [new_CkHttpResponse]
CkHttpRequest_put_HttpVerb $req "POST"
CkHttpRequest_put_ContentType $req "application/x-www-form-urlencoded"
ERROR: Assignment type mismatch. ExpressionType=HttpResponse, atgType=ckbool
if {$success == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkHttpRequest $req
delete_CkJsonObject $jsonParam1
delete_CkHttpResponse $resp
exit
}
puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttp $http
delete_CkHttpRequest $req
delete_CkJsonObject $jsonParam1
delete_CkHttpResponse $resp
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": [
]
}