Report whether a token is active
POST
https://api.testingapis.com/api/auth/oauth/introspectReport whether a token is active (RFC 7662).
Body (form or JSON): token. Unknown, expired and revoked tokens return {"active": false}.
Request body
Optional. application/x-www-form-urlencoded. Token to inspect.
Example body
token={{oauthAccessToken}}Responses
- 200
- Token status and, when active, its scope, client, subject and expiry.
Example
Request
curl -X POST "https://api.testingapis.com/api/auth/oauth/introspect" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic YXBpYmVlLWNsaWVudDphcGliZWUtc2VjcmV0" \
--data-urlencode "token={{oauthAccessToken}}"Response200 OK
{
"active": true,
"scope": "read profile",
"client_id": "apibee-client",
"username": "apibee",
"sub": "apibee",
"token_type": "Bearer",
"iat": 1790792795,
"exp": 1790796395
}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/auth/oauth/introspect", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic YXBpYmVlLWNsaWVudDphcGliZWUtc2VjcmV0",
},
body: "token=%7B%7BoauthAccessToken%7D%7D",
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"POST",
"https://api.testingapis.com/api/auth/oauth/introspect",
headers={
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic YXBpYmVlLWNsaWVudDphcGliZWUtc2VjcmV0",
},
data="token=%7B%7BoauthAccessToken%7D%7D".encode("utf-8"),
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/auth/oauth/introspect"))
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Authorization", "Basic YXBpYmVlLWNsaWVudDphcGliZWUtc2VjcmV0")
.method("POST", HttpRequest.BodyPublishers.ofString("token=%7B%7BoauthAccessToken%7D%7D"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}