MCPcopy Index your code
hub / github.com/coder/coder / RevokeOAuth2Token

Method RevokeOAuth2Token

codersdk/oauth2.go:375–392  ·  view source on GitHub ↗

RevokeOAuth2Token revokes a specific OAuth2 token using RFC 7009 token revocation.

(ctx context.Context, clientID uuid.UUID, token string)

Source from the content-addressed store, hash-verified

373
374// RevokeOAuth2Token revokes a specific OAuth2 token using RFC 7009 token revocation.
375func (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.

Callers 1

TestOAuth2CoderClientFunction · 0.80

Calls 6

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
EncodeMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45

Tested by 1

TestOAuth2CoderClientFunction · 0.64