Revoke OAuth Authorization
curl --request DELETE \
--url https://api.example.com/v1/auth/oauth/revoke \
--header 'Authorization: <authorization>' \
--header 'x-client-key: <x-client-key>'import requests
url = "https://api.example.com/v1/auth/oauth/revoke"
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>"
}
response = requests.delete(url, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'x-client-key': '<x-client-key>', Authorization: '<authorization>'}
};
fetch('https://api.example.com/v1/auth/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://api.example.com/v1/auth/oauth/revoke",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"x-client-key: <x-client-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"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/auth/oauth/revoke"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("x-client-key", "<x-client-key>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.example.com/v1/auth/oauth/revoke")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/auth/oauth/revoke")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyAuthentication
Revoke OAuth Authorization
Permanently revoke OAuth authorization and invalidate all tokens
DELETE
/
v1
/
auth
/
oauth
/
revoke
Revoke OAuth Authorization
curl --request DELETE \
--url https://api.example.com/v1/auth/oauth/revoke \
--header 'Authorization: <authorization>' \
--header 'x-client-key: <x-client-key>'import requests
url = "https://api.example.com/v1/auth/oauth/revoke"
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>"
}
response = requests.delete(url, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'x-client-key': '<x-client-key>', Authorization: '<authorization>'}
};
fetch('https://api.example.com/v1/auth/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://api.example.com/v1/auth/oauth/revoke",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"x-client-key: <x-client-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"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/auth/oauth/revoke"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("x-client-key", "<x-client-key>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.example.com/v1/auth/oauth/revoke")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/auth/oauth/revoke")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyOverview
Revoke OAuth authorization and invalidate all access/refresh tokens for the authenticated client. After revocation:- All existing access tokens become invalid
- All existing refresh tokens become invalid
- Client must restart OAuth flow from Step 1 to regain access
This does NOT log the user out of their account - it only revokes the OAuth client’s access.
Request
Headers
string
required
Your public API client key
string
required
Bearer tokenFormat:
Bearer ACCESS_TOKENResponse
{
"success": true
}
Code Examples
curl -X DELETE "https://dev.api.baanx.com/v1/auth/oauth/revoke" \
-H "x-client-key: your-client-key" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
async function revokeAccess() {
const response = await fetch('https://dev.api.baanx.com/v1/auth/oauth/revoke', {
method: 'DELETE',
headers: {
'x-client-key': 'your-client-key',
'Authorization': `Bearer ${accessToken}`
}
});
if (response.ok) {
// Clear stored tokens
localStorage.removeItem('access_token');
localStorage.removeItem('refresh_token');
console.log('Authorization revoked successfully');
}
}
Use Cases
- User explicitly revokes third-party app access
- Security: Invalidate tokens after detecting suspicious activity
- Logout: Clean up authorization on user logout
- Compliance: Allow users to manage connected applications
Was this page helpful?