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

Method oAuth1Callback

internal/api/external_oauth.go:149–177  ·  view source on GitHub ↗
(ctx context.Context, providerType string)

Source from the content-addressed store, hash-verified

147}
148
149func (a *API) oAuth1Callback(ctx context.Context, providerType string) (*OAuthProviderData, error) {
150 oAuthProvider, _, err := a.OAuthProvider(ctx, providerType)
151 if err != nil {
152 return nil, apierrors.NewBadRequestError(apierrors.ErrorCodeOAuthProviderNotSupported, "Unsupported provider: %+v", err).WithInternalError(err)
153 }
154 oauthToken := getRequestToken(ctx)
155 oauthVerifier := getOAuthVerifier(ctx)
156 var accessToken *oauth.AccessToken
157 var userData *provider.UserProvidedData
158 if twitterProvider, ok := oAuthProvider.(*provider.TwitterProvider); ok {
159 accessToken, err = twitterProvider.Consumer.AuthorizeToken(&oauth.RequestToken{
160 Token: oauthToken,
161 }, oauthVerifier)
162 if err != nil {
163 return nil, apierrors.NewInternalServerError("Unable to retrieve access token").WithInternalError(err)
164 }
165 userData, err = twitterProvider.FetchUserData(ctx, accessToken)
166 if err != nil {
167 return nil, apierrors.NewInternalServerError("Error getting user email from external provider").WithInternalError(err)
168 }
169 }
170
171 return &OAuthProviderData{
172 userData: userData,
173 token: accessToken.Token,
174 refreshToken: "",
175 }, nil
176
177}
178
179// OAuthProvider returns the corresponding oauth provider as an OAuthProvider interface
180func (a *API) OAuthProvider(ctx context.Context, name string) (provider.OAuthProvider, conf.OAuthProviderConfiguration, error) {

Callers 1

handleOAuthCallbackMethod · 0.95

Calls 7

OAuthProviderMethod · 0.95
NewBadRequestErrorFunction · 0.92
NewInternalServerErrorFunction · 0.92
getRequestTokenFunction · 0.85
getOAuthVerifierFunction · 0.85
FetchUserDataMethod · 0.80
WithInternalErrorMethod · 0.45

Tested by

no test coverage detected