I want to be able to sign in through Google OAuth to get token and refresh token only for this scope: https://www.googleapis.com/auth/gmail.readonly. In my app I’ve already logged in the user, whether it be by social auth (Google, Microsoft) or by supabase magic link. So I don’t want to change the already logged in user I just want to grab the tokens and then do stuff with them.
Haven’t been able to figure out how, any help would be appreciated!
You will have to set up a separate OAuth flow for the Connect to Gmail button, but first add the scope in Google Console. Google redirects back with a temporary code in the URL that you can pass to your edge function that will exchange for the token so you can safely store them in the database. A much simpler approach would be using the Sign In OAuth Provider action, but this would force a new login flow.