supabase: Google Sign-In Error in Chrome Extension: Invalid Request (Error 400: redirect_uri_mismatch)
When attempting to sign in with Google in a Chrome extension using Supabase authentication, the following error occurs:
Access blocked: This app's request is invalid
You can't sign in because this app sent an invalid request. You can try again later, or contact the developer about this issue.
Error 400: redirect_uri_mismatch
Reproduction Repository
I have created a minimal repository to reproduce this issue: https://github.com/btahir/vite-supabase-chrome-extension
This repository contains a simplified Chrome extension built with Vite and Supabase, demonstrating the Google Sign-In error.
Steps to Reproduce
- Clone the reproduction repository:
git clone https://github.com/btahir/vite-supabase-chrome-extension - Follow the setup instructions in the repository’s README
- Load the extension in Chrome
- Attempt to sign in using Google authentication
- Observe the error message described above
Expected Behavior
The sign-in process should complete successfully, allowing the Chrome extension to authenticate with Supabase using Google Sign-In.
Actual Behavior
The sign-in process fails with an invalid request error, specifically a redirect_uri_mismatch.
- Are there specific steps or configurations needed for Google Sign-In in a Chrome extension when using Supabase?
- Does Supabase have any documentation or examples specifically for Chrome extension integration?
- Are there known limitations or extra steps required for OAuth flows in Chrome extensions that might be affecting the Supabase integration?
- How should the redirect URI be configured in the Google Cloud Console for a Chrome extension?
Specific Error Details
The full error message includes the following details:
Error 400: redirect_uri_mismatch
Request details: flowName=GeneralOAuthFlow
Any assistance in resolving this Chrome extension-specific authentication issue would be greatly appreciated. Thank you!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 20 (3 by maintainers)
Why is this closed @Hallidayo ? The docs should be updated because the same problem still does exist. It looks like it’s not really possible to perform a web authentication flow for a Chrome extension.
Hi all, We’re going to close this one due to inactivity. Please feel free to reopen if you’re still having issues here or open a new issue.
I have the same issue…
@btahir I have followed the chrome extension instructions however they do not work and I am still getting the same
Error 400: redirect_uri_mismatcherror. I will attempt the solutions provided above however I believe that the supabase documentation on goggle auth with extension is not extensive.@gunayanil I agree I think the docs at the very least need to be updated.
I tried this solution. It wroks! https://github.com/orgs/supabase/discussions/19547#discussioncomment-8786611
yes – we did end up getting it working.
the redirect_uri_mismatch was solved for me by following the Manifest Key Stack Overflow instructions I mentioned above. once that was working, I was able to implement:
ultimately login with Apple was even more of a headache, so I got pretty fed up with the extension and put it on pause for now.
creating a web application client and adding redirecturi to it matching the one in code made it work for me.
Seems like using launchWebAuthFlow with chrome extension Client type is not possible
https://groups.google.com/a/chromium.org/g/chromium-extensions/c/9jADkbZcdYE
Yes, indeed the docs are incorrect. As you need to do a workaround with the web app instead of “Chrome extension”.
FWIW, with the
Chrome Extensionthe Chrome identity API provides,chrome.identity.getAuthTokenwhich can be used to get theaccess_token. If only Supabase could sign in using anaccess_tokeninstead of relying on an “id_token”, it would be much simpler experience here.I found this comment had instructions that ultimately fixed this for me – the key points being to find the manifest key from the developer console, as well as adding a Web endpoint with the redirect URL included in the credentials. copying from SO:
however, now that it’s working, I’m running into the exact same challenges described here that basically cause the login to fail whenever you click outside of the extension. might be worth starting with the strategy he outlines instead (that’s what I’m hoping to implement next).