How to implement Google Incremental authorization using Supabase

55 Views Asked by At

I have a next.js application that uses supabase and google oauth. I want users to be able to sign into my website with the most basic scopes: profile and email.

When users sign in, they get redirected to the dashboard. However, on my dashboard, I have a button that enables me read access to the user's emails. How can I implement this? How can this button get the extra scope from the user?

Here is my code so far:

On my sign in page, I have this logic:

const handleSignIn = async () => {
  const supabase = supabaseBrowser();
  const { error } = await supabase.auth.signInWithOAuth({
    provider: "google",
    options: {
      redirectTo: "http://localhost:3000/dashboard"
    },
  });
  if (error) {
    console.error(error);
  }
};

Now how can I create that button on my dashboard page that gives me the extra gmail scope needed to read user's emails for an additional feature?

How would I tell google oauth that I now need this new scope?

0

There are 0 best solutions below