Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkHttpRequest.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkHttpRequest req;
HCkJsonObject jsonParam2;
HCkJsonObject jsonParam3;
HCkJsonObject jsonParam5;
HCkHttpResponse resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
req = CkHttpRequest_Create();
CkHttpRequest_AddParam(req,"grant_type","refresh_token");
jsonParam2 = CkJsonObject_Create();
CkHttpRequest_AddParam(req,"client_id",CkJsonObject_emit(jsonParam2));
jsonParam3 = CkJsonObject_Create();
CkHttpRequest_AddParam(req,"client_secret",CkJsonObject_emit(jsonParam3));
CkHttpRequest_AddParam(req,"scope","read+write");
jsonParam5 = CkJsonObject_Create();
CkHttpRequest_AddParam(req,"refresh_token",CkJsonObject_emit(jsonParam5));
resp = CkHttp_PostUrlEncoded(http,"https://api.pandadoc.com/oauth2/access_token",req);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkJsonObject_Dispose(jsonParam2);
CkJsonObject_Dispose(jsonParam3);
CkJsonObject_Dispose(jsonParam5);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkJsonObject_Dispose(jsonParam2);
CkJsonObject_Dispose(jsonParam3);
CkJsonObject_Dispose(jsonParam5);
}
Curl Command
curl -X POST
--data-urlencode 'grant_type=refresh_token'
--data-urlencode 'client_id={{client_id}}'
--data-urlencode 'client_secret={{client_secret}}'
--data-urlencode 'scope=read+write'
--data-urlencode 'refresh_token={{refresh_token}}'
https://api.pandadoc.com/oauth2/access_token
Postman Collection Item JSON
{
"name": "Refresh Access Token",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = JSON.parse(responseBody);",
"if (jsonData.access_token !== undefined) {",
" postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);",
"}",
"if (jsonData.refresh_token !== undefined) {",
" postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "refresh_token",
"type": "text"
},
{
"key": "client_id",
"value": "{{client_id}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{client_secret}}",
"type": "text"
},
{
"key": "scope",
"value": "read+write",
"type": "text"
},
{
"key": "refresh_token",
"value": "{{refresh_token}}",
"type": "text"
}
]
},
"url": {
"raw": "https://api.pandadoc.com/oauth2/access_token",
"protocol": "https",
"host": [
"api",
"pandadoc",
"com"
],
"path": [
"oauth2",
"access_token"
]
},
"description": "For details go to [https://developers.pandadoc.com/v1/reference#refresh-access_token](https://developers.pandadoc.com/v1/reference#refresh-access_token).\n\nFor details of authentication process go to [https://developers.pandadoc.com/v1/reference#authentication-process](https://developers.pandadoc.com/v1/reference#authentication-process)."
},
"response": [
]
}