Revoke OAuth2 tokens (RFC 7009).
POST
application/x-www-form-urlencoded- body
client_id?stringClient ID, required unless sent as the HTTP Basic username
client_secret?stringClient secret, required for a confidential client unless sent as the HTTP Basic password. Public clients (token_endpoint_auth_method=none) send no secret.
token*stringThe token to revoke
token_type_hint?stringHint about token type (access_token or refresh_token)
Token successfully revoked. A 200 does not confirm that the token existed or belonged to the client
The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/oauth2/revoke" \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-binary "@{file}"import { readFile } from "node:fs/promises";const { CODER_URL } = process.env;const url = `${CODER_URL}/oauth2/revoke`;const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded", }, body: await readFile("{file}"),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/oauth2/revoke"response = requests.post( url, headers={ "Content-Type": "application/x-www-form-urlencoded", }, data=open("{file}", "rb"),)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os")func main() { body, err := os.Open("{file}") if err != nil { panic(err) } defer body.Close() url := os.Getenv("CODER_URL") + "/oauth2/revoke" req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response
Empty