Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global_Ref.html">Global Unlock Sample for sample code.
http := chilkat.NewHttp()
var success bool
req := chilkat.NewHttpRequest()
jsonParam1 := chilkat.NewJsonObject()
req.AddParam("assertion",*jsonParam1.Emit())
req.AddParam("grant_type","urn:ietf:params:oauth:grant-type:jwt-bearer")
req.AddHeader("Authorization","Basic {{encodedKeys}}")
resp := http.PostUrlEncoded("https://{{hostenv}}/oauth/token",req)
if http.LastMethodSuccess() == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
req.DisposeHttpRequest()
jsonParam1.DisposeJsonObject()
return
}
fmt.Println(resp.StatusCode())
fmt.Println(resp.BodyStr())
resp.DisposeHttpResponse()
http.DisposeHttp()
req.DisposeHttpRequest()
jsonParam1.DisposeJsonObject()
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": [
]
}