mirror of https://github.com/kortix-ai/suna.git
5.6 KiB
5.6 KiB
Google OAuth Setup Guide
This guide will help you configure Google Sign-In for your Suna application to avoid common errors like "Access blocked: This app's request is invalid".
Prerequisites
- A Google Cloud Console account
- Your Supabase project URL and anon key
Step 1: Create a Google Cloud Project
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Enter a project name (e.g., "Suna App")
- Click "Create"
Step 2: Configure OAuth Consent Screen
- In the Google Cloud Console, go to "APIs & Services" → "OAuth consent screen"
- Select "External" user type (unless you have a Google Workspace account)
- Click "Create"
- Fill in the required fields:
- App name: Your application name (e.g., "Suna")
- User support email: Your email address
- App logo: Optional, but recommended
- App domain: Your domain (for local dev, skip this)
- Authorized domains: Add your domain(s)
- Developer contact information: Your email address
- Click "Save and Continue"
- Scopes: Click "Add or Remove Scopes"
- Select
.../auth/userinfo.email
- Select
.../auth/userinfo.profile
- Select
openid
- Click "Update"
- Select
- Click "Save and Continue"
- Test users: Add test email addresses if in testing mode
- Click "Save and Continue"
- Review and click "Back to Dashboard"
Step 3: Create OAuth 2.0 Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Select "Web application" as the application type
- Configure the client:
- Name: "Suna Web Client" (or any name you prefer)
- Authorized JavaScript origins:
- Add
http://localhost:3000
(for local development) - Add
https://yourdomain.com
(for production) - Add your Supabase URL (e.g.,
https://yourproject.supabase.co
)
- Add
- Authorized redirect URIs:
- Add
http://localhost:3000/auth/callback
(for local development) - Add
https://yourdomain.com/auth/callback
(for production) - Add your Supabase auth callback URL:
https://yourproject.supabase.co/auth/v1/callback
- Add
- Click "Create"
- Important: Copy the "Client ID" - you'll need this
Step 4: Configure Supabase
- Go to your Supabase Dashboard
- Select your project
- Go to "Authentication" → "Providers"
- Find "Google" and enable it
- Add your Google OAuth credentials:
- Client ID: Paste the Client ID from Step 3
- Client Secret: Leave empty (not needed for web applications)
- Authorized Client IDs: Add your Client ID here as well
- Click "Save"
Step 5: Configure Your Application
-
Add the Google Client ID to your environment variables:
Frontend (
frontend/.env.local
):NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-client-id-here
-
Restart your development server
Step 6: Test Your Setup
- Open your application in a browser
- Click the "Continue with Google" button
- You should see the Google sign-in popup
- Select an account and authorize the application
- You should be redirected back to your application and logged in
Common Issues and Solutions
"Access blocked: This app's request is invalid"
This error usually means:
- Missing redirect URI: Make sure all your redirect URIs are added in Google Cloud Console
- Wrong Client ID: Verify you're using the correct Client ID
- OAuth consent screen not configured: Complete all required fields in the consent screen
"redirect_uri_mismatch"
- Check that your redirect URIs in Google Cloud Console exactly match your application URLs
- Include the protocol (
http://
orhttps://
) - Don't include trailing slashes
- For local development, use
http://localhost:3000
, nothttp://127.0.0.1:3000
"invalid_client"
- Verify your Client ID is correct in the environment variables
- Make sure you're using the Web application client ID, not a different type
- Check that the OAuth client hasn't been deleted in Google Cloud Console
Google button doesn't appear
- Check browser console for errors
- Verify
NEXT_PUBLIC_GOOGLE_CLIENT_ID
is set in your environment - Make sure the Google Identity Services script is loading
Production Deployment
When deploying to production:
-
Update Google Cloud Console:
- Add your production domain to "Authorized JavaScript origins"
- Add your production callback URL to "Authorized redirect URIs"
- Update the OAuth consent screen with production information
-
Update your production environment variables:
- Set
NEXT_PUBLIC_GOOGLE_CLIENT_ID
in your deployment platform
- Set
-
Verify Supabase settings:
- Ensure Google provider is enabled
- Confirm the Client ID is set correctly
Security Best Practices
- Never commit your Client ID to version control - always use environment variables
- Use HTTPS in production - Google requires secure connections for OAuth
- Restrict your OAuth client - Only add the domains you actually use
- Review permissions regularly - Remove unused test users and unnecessary scopes
- Monitor usage - Check Google Cloud Console for unusual activity
Publishing Your App
If you want to remove the "unverified app" warning:
- Go to "OAuth consent screen" in Google Cloud Console
- Click "Publish App"
- Google may require verification for certain scopes
- Follow the verification process if required
Need Help?
If you're still experiencing issues:
- Check the browser console for detailed error messages
- Verify all URLs and IDs are correctly copied
- Ensure your Supabase project is properly configured
- Try using an incognito/private browser window to rule out cache issues