PureBasic / DocuSign Admin API / 03 Refresh Access Token
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttpRequest.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
req.i = CkHttpRequest::ckCreate()
If req.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
jsonParam1.i = CkJsonObject::ckCreate()
If jsonParam1.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpRequest::ckAddParam(req,"refresh_token",CkJsonObject::ckEmit(jsonParam1))
CkHttpRequest::ckAddParam(req,"grant_type","refresh_token")
CkHttpRequest::ckAddHeader(req,"Authorization","Basic {{encodedKeys}}")
resp.i = CkHttp::ckPostUrlEncoded(http,"https://{{hostenv}}/oauth/token",req)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkHttpRequest::ckDispose(req)
CkJsonObject::ckDispose(jsonParam1)
ProcedureReturn
EndIf
Debug Str(CkHttpResponse::ckStatusCode(resp))
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkHttpRequest::ckDispose(req)
CkJsonObject::ckDispose(jsonParam1)
ProcedureReturn
EndProcedure
Curl Command
curl -X POST
-H "Authorization: Basic {{encodedKeys}}"
--data-urlencode 'refresh_token={{refreshToken}}'
--data-urlencode 'grant_type=refresh_token'
https://{{hostenv}}/oauth/token
Postman Collection Item JSON
{
"name": "03 Refresh 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": "refresh_token",
"value": "{{refreshToken}}"
},
{
"key": "grant_type",
"value": "refresh_token"
}
]
},
"url": {
"raw": "https://{{hostenv}}/oauth/token",
"protocol": "https",
"host": [
"{{hostenv}}"
],
"path": [
"oauth",
"token"
]
}
},
"response": [
]
}