lianja / DocuSign Admin API / 01 Authorize Code Grant Access Token
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loReq = createobject("CkHttpRequest")
loJsonParam1 = createobject("CkJsonObject")
loReq.AddParam("code",loJsonParam1.Emit())
loReq.AddParam("grant_type","authorization_code")
loReq.AddHeader("Authorization","Basic {{encodedKeys}}")
loResp = loHttp.PostUrlEncoded("https://{{hostenv}}/oauth/token",loReq)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loReq
release loJsonParam1
return
endif
? str(loResp.StatusCode)
? loResp.BodyStr
release loResp
release loHttp
release loReq
release loJsonParam1
Curl Command
curl -X POST
-H "Authorization: Basic {{encodedKeys}}"
--data-urlencode 'code={{codeFromUrl}}'
--data-urlencode 'grant_type=authorization_code'
https://{{hostenv}}/oauth/token
Postman Collection Item JSON
{
"name": "01 Authorize Code Grant 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": "code",
"value": "{{codeFromUrl}}"
},
{
"key": "grant_type",
"value": "authorization_code"
}
]
},
"url": {
"raw": "https://{{hostenv}}/oauth/token",
"protocol": "https",
"host": [
"{{hostenv}}"
],
"path": [
"oauth",
"token"
]
}
},
"response": [
]
}