Bug Report
Describe the bug
I'm trying to implement Google OAuth authentication in a Chrome extension using Supabase Auth, but I'm getting a redirect_uri_mismatch error when attempting to authenticate.
Environment
- Supabase JS Version:
^2.38.4
- Platform: Chrome Extension (Manifest V3)
- Framework: React + TypeScript + Vite
- Project URL:
https://bafbefwknhhupvmnzyij.supabase.co
Configuration Details
Google Cloud Console OAuth Client
- Application Type: Chrome extension
- Item ID:
pbfhgmnkdjpldbjdmdamheofpjonddip (actual Chrome extension ID)
- Client ID:
731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.com
Chrome Extension manifest.json
{
"manifest_version": 3,
"permissions": ["identity", "storage"],
"oauth2": {
"client_id": "731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.com",
"scopes": ["openid", "email", "profile"]
}
}
Supabase Configuration
- Google Auth Provider: Enabled
- Client ID:
731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.com
- Client Secret: (left empty as per Chrome extension documentation)
- Callback URL:
https://bafbefwknhhupvmnzyij.supabase.co/auth/v1/callback
Implementation Code
// Chrome extension Google auth implementation
export const signInWithGoogle = async (): Promise<AuthResult> => {
try {
const manifest = chrome.runtime.getManifest()
const oauth2 = manifest.oauth2
if (!oauth2 || !oauth2.client_id) {
return { success: false, error: '缺少 Google OAuth 配置' }
}
// Build Google OAuth URL
const redirectUri = `https://${chrome.runtime.id}.chromiumapp.org`
const url = new URL('https://accounts.google.com/o/oauth2/auth')
url.searchParams.set('client_id', oauth2.client_id)
url.searchParams.set('response_type', 'id_token')
url.searchParams.set('access_type', 'offline')
url.searchParams.set('redirect_uri', redirectUri)
url.searchParams.set('scope', oauth2.scopes?.join(' ') || 'openid email profile')
// Launch Chrome identity auth flow
return new Promise((resolve) => {
chrome.identity.launchWebAuthFlow(
{
url: url.href,
interactive: true,
},
async (redirectedTo) => {
if (chrome.runtime.lastError) {
resolve({
success: false,
error: chrome.runtime.lastError.message || '认证失败'
})
return
}
if (!redirectedTo) {
resolve({ success: false, error: '认证被取消或失败' })
return
}
try {
// Extract ID token from redirect URL
const urlObj = new URL(redirectedTo)
const params = new URLSearchParams(urlObj.hash.substring(1))
const idToken = params.get('id_token')
if (!idToken) {
resolve({ success: false, error: '无法获取认证令牌' })
return
}
// Sign in with Supabase using ID token
const { data, error } = await supabase.auth.signInWithIdToken({
provider: 'google',
token: idToken,
})
if (error) {
resolve({ success: false, error: error.message })
return
}
resolve({ success: true, user: data.user })
} catch (error) {
resolve({ success: false, error: '处理认证令牌时出错' })
}
}
)
})
} catch (error) {
return { success: false, error: '登录过程中出现未知错误' }
}
}
Error Details
Error Message:
错误 400: redirect_uri_mismatch
无法登录,因为此应用发送的请求无效
Debug Output:
Chrome Extension ID: pbfhgmnkdjpldbjdmdamheofpjonddip
Redirect URI: https://pbfhgmnkdjpldbjdmdamheofpjonddip.chromiumapp.org
Client ID: 731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.com
Expected behavior
The Chrome extension should successfully authenticate with Google OAuth and sign in the user to Supabase.
Steps to reproduce
- Create a Chrome extension with Manifest V3
- Configure Google Cloud Console OAuth client as "Chrome extension" type
- Enable Google auth provider in Supabase
- Implement authentication using
chrome.identity.launchWebAuthFlow()
- Call
supabase.auth.signInWithIdToken() with the obtained ID token
- Get
redirect_uri_mismatch error
Questions
- Should Chrome extensions use "Chrome extension" or "Web application" OAuth client type for Supabase integration?
- Is there a specific redirect URI that should be configured in Google Cloud Console for Chrome extensions?
- Are there any special considerations for Supabase Auth with Chrome extensions?
References
- Supabase Auth with Google for Chrome Extensions
- Chrome Extension ID:
pbfhgmnkdjpldbjdmdamheofpjonddip
- The documentation mentions "you do not have to configure the OAuth flow in the Supabase Dashboard to sign in with Google inside Chrome extensions" - but we still need to enable the Google provider, correct?
Additional context
I followed the official Supabase documentation for Chrome extensions, but the configuration seems to be causing issues. Any guidance on the proper setup would be greatly appreciated.
Environment Info:
- Chrome Version: Latest
- OS: Windows 11
- Node.js: Latest LTS
- Build Tool: Vite

Bug Report
Describe the bug
I'm trying to implement Google OAuth authentication in a Chrome extension using Supabase Auth, but I'm getting a
redirect_uri_mismatcherror when attempting to authenticate.Environment
^2.38.4https://bafbefwknhhupvmnzyij.supabase.coConfiguration Details
Google Cloud Console OAuth Client
pbfhgmnkdjpldbjdmdamheofpjonddip(actual Chrome extension ID)731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.comChrome Extension manifest.json
{ "manifest_version": 3, "permissions": ["identity", "storage"], "oauth2": { "client_id": "731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.com", "scopes": ["openid", "email", "profile"] } }Supabase Configuration
731029100183-2vm4ql5kgke9oimgi6nodb19tjmnr6e2.apps.googleusercontent.comhttps://bafbefwknhhupvmnzyij.supabase.co/auth/v1/callbackImplementation Code
Error Details
Error Message:
Debug Output:
Expected behavior
The Chrome extension should successfully authenticate with Google OAuth and sign in the user to Supabase.
Steps to reproduce
chrome.identity.launchWebAuthFlow()supabase.auth.signInWithIdToken()with the obtained ID tokenredirect_uri_mismatcherrorQuestions
References
pbfhgmnkdjpldbjdmdamheofpjonddipAdditional context
I followed the official Supabase documentation for Chrome extensions, but the configuration seems to be causing issues. Any guidance on the proper setup would be greatly appreciated.
Environment Info: