signInWithOAuth()
Log in an existing user via a third-party provider.
1const { data, error } = await supabase.auth.signInWithOAuth({
2 provider: 'github'
3})
Parameters#
SignInWithOAuthCredentialsrequired
object
No description provided.
providerrequired
Provider
One of the providers supported by GoTrue.
optionsoptional
object
No description provided.
queryParamsoptional
object
An object of query params
redirectTooptional
string
A URL to send the user to after they are confirmed.
scopesoptional
string
A space-separated list of scopes granted to the OAuth application.
Properties
Properties
Notes#
- This method is used for signing in using a third-party provider.
- Supabase supports many different third-party providers.
Examples#
Sign in using a third-party provider#
1const { data, error } = await supabase.auth.signInWithOAuth({
2 provider: 'github'
3})
Sign in using a third-party provider with redirect#
When the third-party provider successfully authenticates the user, the provider redirects the user to the Supabase Auth callback URL where they are further redirected to the URL specified in the redirectTo
parameter. This parameter defaults to the SITE_URL
.
You can modify the SITE_URL
or add additional redirect URLs. You can use wildcard match patterns to support preview URLs from providers like Netlify and Vercel.
1const { data, error } = await supabase.auth.signInWithOAuth({
2 provider: 'github'
3 options: {
4 redirectTo: 'https://example.com/welcome'
5 }
6}
Sign in with scopes#
If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token. You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider. The list of scopes will be documented by the third-party provider you are using and specifying scopes will enable you to use the OAuth provider token to call additional APIs supported by the third-party provider to get more information.
1const { data, error } = await supabase.auth.signInWithOAuth({
2 provider: 'github'
3 options: {
4 scopes: 'repo gist notifications'
5 }
6})
7const oAuthToken = data.session.provider_token // use to access provider API