Back to Collection Items
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As New ChilkatHttp
Dim success As Long
Dim req As New ChilkatHttpRequest
Dim jsonParam1 As New ChilkatJsonObject
req.AddParam "refresh_token",jsonParam1.Emit()
req.AddParam "grant_type","refresh_token"
req.AddHeader "Authorization","Basic {{encodedKeys}}"
Dim resp As ChilkatHttpResponse
Set resp = http.PostUrlEncoded("https://{{hostenv}}/oauth/token",req)
If (http.LastMethodSuccess = 0) Then
Debug.Print http.LastErrorText
Exit Sub
End If
Debug.Print resp.StatusCode
Debug.Print resp.BodyStr
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": [
]
}