Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @req int
-- Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT
EXEC sp_OAMethod @req, 'AddParam', NULL, 'grant_type', 'refresh_token'
DECLARE @jsonParam2 int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonParam2 OUT
EXEC sp_OAMethod @jsonParam2, 'Emit', @sTmp0 OUT
EXEC sp_OAMethod @req, 'AddParam', NULL, 'client_id', @sTmp0
DECLARE @jsonParam3 int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonParam3 OUT
EXEC sp_OAMethod @jsonParam3, 'Emit', @sTmp0 OUT
EXEC sp_OAMethod @req, 'AddParam', NULL, 'client_secret', @sTmp0
EXEC sp_OAMethod @req, 'AddParam', NULL, 'scope', 'read+write'
DECLARE @jsonParam5 int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonParam5 OUT
EXEC sp_OAMethod @jsonParam5, 'Emit', @sTmp0 OUT
EXEC sp_OAMethod @req, 'AddParam', NULL, 'refresh_token', @sTmp0
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostUrlEncoded', @resp OUT, 'https://api.pandadoc.com/oauth2/access_token', @req
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @req
EXEC @hr = sp_OADestroy @jsonParam2
EXEC @hr = sp_OADestroy @jsonParam3
EXEC @hr = sp_OADestroy @jsonParam5
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @req
EXEC @hr = sp_OADestroy @jsonParam2
EXEC @hr = sp_OADestroy @jsonParam3
EXEC @hr = sp_OADestroy @jsonParam5
END
GO
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": [
]
}