Google OAuth integration allows users to sign in with their Google accounts. This provides a convenient authentication method and can streamline the registration process.
Setup Overview
To enable Google login, you need to:
- Create a Google OAuth application
- Configure authorized redirect URIs
- Add credentials to Shadow Store
- Enable the integration
Creating Google OAuth Application
Step 1: Access Google Cloud Console
- Go to Google Cloud Console
- Sign in with your Google account
- Create a new project or select an existing one
Step 2: Enable Google+ API
- Navigate to APIs & Services > Library
- Search for "Google+ API"
- Click on it and enable the API
Step 3: Create OAuth Credentials
- Go to APIs & Services > Credentials
- Click "Create Credentials"
- Select "OAuth client ID"
- Choose "Web application"
Step 4: Configure OAuth Consent Screen
- Navigate to OAuth consent screen
- Fill in required information:
- App name
- User support email
- Developer contact information
- Save and continue
Step 5: Set Authorized Redirect URIs
Add your Shadow Store callback URL:
https://yourdomain.com/auth/google/callback
Replace yourdomain.com with your actual domain.
Important: Use https:// for production domains.
Step 6: Get Client Credentials
After creating the OAuth client:
- Copy the Client ID
- Copy the Client Secret
- Keep these secure
Configuring Shadow Store
Adding Credentials
- Navigate to Admin Panel > Integrations
- Locate Google OAuth section
- Enter your Client ID
- Enter your Client Secret
- Save configuration
Environment Variables
Alternatively, add to your .env file:
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
Testing the Integration
- Log out of Shadow Store
- Go to the login page
- Click "Sign in with Google"
- Authorize the application
- You should be redirected and logged in
User Experience
First-Time Google Login
When a user signs in with Google for the first time:
- They authorize Shadow Store
- A new account is created automatically
- Profile information is imported from Google:
- Name
- Email address
- Profile picture (optional)
- User is logged in immediately
Returning Users
For users who have previously signed in with Google:
- Click "Sign in with Google"
- Select their Google account
- Logged in immediately (no re-authorization needed)
Linking Accounts
Users who created an account with email/password can link their Google account:
- User logs in with email/password
- Navigate to account settings
- Click "Link Google Account"
- Authorize with Google
- Accounts are now linked
- User can sign in with either method
Security Considerations
Scopes:
Shadow Store typically requests:
openid: OpenID Connect authenticationprofile: Basic profile informationemail: Email address
Troubleshooting
Redirect URI Mismatch
Error: "redirect_uri_mismatch"
Solutions:
- Verify redirect URI in Google Console matches exactly
- Check for http vs https
- Ensure no trailing slashes
- Confirm domain is correct
Invalid Client
Error: "invalid_client"
Solutions:
- Verify Client ID is correct
- Check Client Secret is accurate
- Ensure credentials aren't expired
- Confirm project is enabled
Access Denied
Error: User sees "Access Denied"
Solutions:
- Check OAuth consent screen is configured
- Verify app isn't in testing mode with restricted users
- Ensure all required scopes are approved
- Check user's Google account isn't restricted
Login Button Not Appearing
Solutions:
- Verify credentials are configured
- Check integration is enabled
- Clear browser cache
- Restart Shadow Store application