© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•12mo ago•
9 replies
Joe

Update scopes using signInWithOAuth?

Is there an example or recommended pattern for handing scope changes for a user?

Currently users sign in via the google provider with base scopes. Then later within the app there is an option to connect google drive and google sheets. The connect google sheets button is using signInWithOAuth with the additional scopes required but after clicking through the authorization screens and approving the new scopes, checking the provider token still returns the original base scopes
scopes: [
  'https://www.googleapis.com/auth/userinfo.email',
  'https://www.googleapis.com/auth/userinfo.profile',
  'openid'
]
scopes: [
  'https://www.googleapis.com/auth/userinfo.email',
  'https://www.googleapis.com/auth/userinfo.profile',
  'openid'
]

when I expect it to return
scopes: [
  'https://www.googleapis.com/auth/userinfo.email',
  'https://www.googleapis.com/auth/userinfo.profile',
  'openid',
  'https://www.googleapis.com/auth/spreadsheets.readonly',
  'https://www.googleapis.com/auth/drive.readonly',
  'https://www.googleapis.com/auth/drive.metadata.readonly',
]
scopes: [
  'https://www.googleapis.com/auth/userinfo.email',
  'https://www.googleapis.com/auth/userinfo.profile',
  'openid',
  'https://www.googleapis.com/auth/spreadsheets.readonly',
  'https://www.googleapis.com/auth/drive.readonly',
  'https://www.googleapis.com/auth/drive.metadata.readonly',
]


Here is the initial Oauth:
await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    redirectTo: `${process.env.NEXT_PUBLIC_BASE_URL}/auth/callback?redirect_to=${pathname}`,
    queryParams: {
      access_type: 'offline',
      prompt: 'consent',
    },
  },
})
await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    redirectTo: `${process.env.NEXT_PUBLIC_BASE_URL}/auth/callback?redirect_to=${pathname}`,
    queryParams: {
      access_type: 'offline',
      prompt: 'consent',
    },
  },
})

And here is where I am trying to add the new scopes:
const requiredScopesString = REQUIRED_SCOPES.join(' ')
await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    scopes: requiredScopesString,
    redirectTo: `${process.env.NEXT_PUBLIC_BASE_URL}/auth/callback?next=/${params.org_id}/data_sources/google_sheets/new`,
    queryParams: {
      prompt: 'consent',
      access_type: 'offline',
    },
  },
})
const requiredScopesString = REQUIRED_SCOPES.join(' ')
await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    scopes: requiredScopesString,
    redirectTo: `${process.env.NEXT_PUBLIC_BASE_URL}/auth/callback?next=/${params.org_id}/data_sources/google_sheets/new`,
    queryParams: {
      prompt: 'consent',
      access_type: 'offline',
    },
  },
})
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

facebook signInWithOAuth help
SupabaseSSupabase / help-and-questions
5mo ago
Issue with signInWithOAuth() using multiple branches (prod vs staging)
SupabaseSSupabase / help-and-questions
4d ago
Callback for supabase.auth.signInWithOAuth?
SupabaseSSupabase / help-and-questions
3y ago
Cannot redirect to redirectTo url when using the signInWithOAuth function
SupabaseSSupabase / help-and-questions
4mo ago