revoke token
curl --request POST \
--url https://{tenant}/tyk/oauth/revoke \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'X-Tyk-Authorization: <api-key>' \
--data client_id=2a06b398c17f46908de3dffcb71ef87df \
--data token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0= \
--data org_id=6492f66e6ebbc56c6a6bf022 \
--data token_type_hint=access_tokenimport requests
url = "https://{tenant}/tyk/oauth/revoke"
payload = {
"client_id": "2a06b398c17f46908de3dffcb71ef87df",
"token": "eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0=",
"org_id": "6492f66e6ebbc56c6a6bf022",
"token_type_hint": "access_token"
}
headers = {
"X-Tyk-Authorization": "<api-key>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tyk-Authorization': '<api-key>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
client_id: '2a06b398c17f46908de3dffcb71ef87df',
token: 'eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0=',
org_id: '6492f66e6ebbc56c6a6bf022',
token_type_hint: 'access_token'
})
};
fetch('https://{tenant}/tyk/oauth/revoke', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant}/tyk/oauth/revoke",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded",
"X-Tyk-Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{tenant}/tyk/oauth/revoke"
payload := strings.NewReader("client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tyk-Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant}/tyk/oauth/revoke")
.header("X-Tyk-Authorization", "<api-key>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/tyk/oauth/revoke")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tyk-Authorization"] = '<api-key>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token"
response = http.request(request)
puts response.read_body{
"message": "token revoked successfully",
"status": "ok"
}{
"message": "cannot parse form. Form malformed",
"status": "error"
}{
"message": "Attempted administrative access with invalid or missing key!",
"status": "error"
}OAuth
revoke token
revoke a single token
POST
/
tyk
/
oauth
/
revoke
revoke token
curl --request POST \
--url https://{tenant}/tyk/oauth/revoke \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'X-Tyk-Authorization: <api-key>' \
--data client_id=2a06b398c17f46908de3dffcb71ef87df \
--data token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0= \
--data org_id=6492f66e6ebbc56c6a6bf022 \
--data token_type_hint=access_tokenimport requests
url = "https://{tenant}/tyk/oauth/revoke"
payload = {
"client_id": "2a06b398c17f46908de3dffcb71ef87df",
"token": "eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0=",
"org_id": "6492f66e6ebbc56c6a6bf022",
"token_type_hint": "access_token"
}
headers = {
"X-Tyk-Authorization": "<api-key>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tyk-Authorization': '<api-key>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
client_id: '2a06b398c17f46908de3dffcb71ef87df',
token: 'eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0=',
org_id: '6492f66e6ebbc56c6a6bf022',
token_type_hint: 'access_token'
})
};
fetch('https://{tenant}/tyk/oauth/revoke', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant}/tyk/oauth/revoke",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded",
"X-Tyk-Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{tenant}/tyk/oauth/revoke"
payload := strings.NewReader("client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tyk-Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant}/tyk/oauth/revoke")
.header("X-Tyk-Authorization", "<api-key>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/tyk/oauth/revoke")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tyk-Authorization"] = '<api-key>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "client_id=2a06b398c17f46908de3dffcb71ef87df&token=eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0%3D&org_id=6492f66e6ebbc56c6a6bf022&token_type_hint=access_token"
response = http.request(request)
puts response.read_body{
"message": "token revoked successfully",
"status": "ok"
}{
"message": "cannot parse form. Form malformed",
"status": "error"
}{
"message": "Attempted administrative access with invalid or missing key!",
"status": "error"
}Authorizations
Api key
Body
application/x-www-form-urlencoded
token revoked successfully
id of oauth client
Example:
"2a06b398c17f46908de3dffcb71ef87df"
token to be revoked
Example:
"eyJvcmciOiI1ZTIwOTFjNGQ0YWVmY2U2MGMwNGZiOTIiLCJpZCI6IjIyODQ1NmFjNmJlMjRiMzI5MTIyOTdlODQ5NTc4NjJhIiwiaCI6Im11cm11cjY0In0="
Example:
"6492f66e6ebbc56c6a6bf022"
type of token to be revoked, if sent then the accepted values are access_token and refresh_token. String value and optional, of not provided then it will attempt to remove access and refresh tokens that matches
Example:
"access_token"
Was this page helpful?
⌘I