Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global_Ref.html">Global Unlock Sample for sample code.
http := chilkat.NewHttp()
var success bool
req := chilkat.NewHttpRequest()
req.SetHttpVerb("POST")
req.SetPath("/oauth/v2/token/revoke")
req.SetContentType("multipart/form-data")
jsonFormData1 := chilkat.NewJsonObject()
req.AddStringForUpload2("token","",jsonFormData1,"utf-8","application/json")
resp := http.SynchronousRequest("domain.com",443,true,req)
if http.LastMethodSuccess() == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
req.DisposeHttpRequest()
jsonFormData1.DisposeJsonObject()
return
}
fmt.Println(resp.StatusCode())
fmt.Println(resp.BodyStr())
resp.DisposeHttpResponse()
http.DisposeHttp()
req.DisposeHttpRequest()
jsonFormData1.DisposeJsonObject()
Curl Command
curl -X POST
--form 'token={{refresh-token}}'
https://domain.com/oauth/v2/token/revoke
Postman Collection Item JSON
{
"name": "Revoking Tokens",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (responseCode.code === 200)",
"{",
" var jsonData = JSON.parse(responseBody);",
" ",
" if (jsonData.status == \"sucess\")",
" {",
" pm.environment.set(\"refresh-token\", \"\");",
" pm.environment.set(\"access-token\", \"\");",
" pm.environment.set(\"expiry-time\", \"\");",
" }",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "token",
"value": "{{refresh-token}}",
"type": "text"
}
]
},
"url": {
"raw": "{{accounts-domain}}/oauth/v2/token/revoke",
"host": [
"{{accounts-domain}}"
],
"path": [
"oauth",
"v2",
"token",
"revoke"
]
},
"description": "### Step 5: Revoking Tokens\n\nIn case if you wish to revoke the refresh_token, use the below approach."
},
"response": [
]
}