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

Method TokenRevocationRequestGitHub

coderd/externalauth/externalauth.go:638–650  ·  view source on GitHub ↗
(ctx context.Context, link database.ExternalAuthLink)

Source from the content-addressed store, hash-verified

636}
637
638func (c *Config) TokenRevocationRequestGitHub(ctx context.Context, link database.ExternalAuthLink) (*http.Request, error) {
639 // GitHub doesn't follow RFC spec
640 // https://docs.github.com/en/rest/apps/oauth-applications?apiVersion=2022-11-28#delete-an-app-authorization
641 body := fmt.Sprintf("{\"access_token\":%q}", link.OAuthAccessToken)
642 req, err := http.NewRequestWithContext(ctx, http.MethodDelete, c.RevokeURL, strings.NewReader(body))
643 if err != nil {
644 return nil, err
645 }
646 req.Header.Add("Accept", "application/vnd.github+json")
647 req.Header.Add("X-GitHub-Api-Version", "2022-11-28")
648 req.SetBasicAuth(c.ClientID, c.ClientSecret)
649 return req, nil
650}
651
652func (c *Config) TokenRevocationResponseOk(res *http.Response) bool {
653 // RFC spec on successful revocation returns 200, GitHub 204

Callers 1

Calls 1

AddMethod · 0.65

Tested by

no test coverage detected