RevokeOAuth2Token revokes a specific OAuth2 token using RFC 7009 token revocation.
(ctx context.Context, clientID uuid.UUID, token string)
| 373 | |
| 374 | // RevokeOAuth2Token revokes a specific OAuth2 token using RFC 7009 token revocation. |
| 375 | func (c *Client) RevokeOAuth2Token(ctx context.Context, clientID uuid.UUID, token string) error { |
| 376 | form := url.Values{} |
| 377 | form.Set("token", token) |
| 378 | // Client authentication is handled via the client_id in the app middleware |
| 379 | form.Set("client_id", clientID.String()) |
| 380 | |
| 381 | res, err := c.Request(ctx, http.MethodPost, "/oauth2/revoke", strings.NewReader(form.Encode()), func(r *http.Request) { |
| 382 | r.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| 383 | }) |
| 384 | if err != nil { |
| 385 | return err |
| 386 | } |
| 387 | defer res.Body.Close() |
| 388 | if res.StatusCode != http.StatusOK { |
| 389 | return ReadBodyAsError(res) |
| 390 | } |
| 391 | return nil |
| 392 | } |
| 393 | |
| 394 | // RevokeOAuth2ProviderApp completely revokes an app's access for the |
| 395 | // authenticated user. |