MCPcopy Create free account
hub / github.com/supabase/auth / Token

Method Token

internal/api/token.go:40–68  ·  view source on GitHub ↗

Token is the endpoint for OAuth access token requests

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

38
39// Token is the endpoint for OAuth access token requests
40func (a *API) Token(w http.ResponseWriter, r *http.Request) error {
41 ctx := r.Context()
42 grantType := r.FormValue("grant_type")
43
44 handler := a.ResourceOwnerPasswordGrant
45 limiter := a.limiterOpts.Token
46
47 switch grantType {
48 case "password":
49 // set above
50 case "refresh_token":
51 handler = a.RefreshTokenGrant
52 case "id_token":
53 handler = a.IdTokenGrant
54 case "pkce":
55 handler = a.PKCE
56 case "web3":
57 handler = a.Web3Grant
58 limiter = a.limiterOpts.Web3
59 default:
60 return apierrors.NewBadRequestError(apierrors.ErrorCodeInvalidCredentials, "unsupported_grant_type")
61 }
62
63 if err := a.performRateLimiting(limiter, r); err != nil {
64 return err
65 }
66
67 return handler(ctx, w, r)
68}
69
70// ResourceOwnerPasswordGrant implements the password grant type flow
71func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWriter, r *http.Request) error {

Callers

nothing calls this directly

Calls 3

performRateLimitingMethod · 0.95
NewBadRequestErrorFunction · 0.92
handlerFunction · 0.85

Tested by

no test coverage detected