Overview
The Google provider enables authentication using Google accounts. It implements the OAuth 2.0 protocol and supports PKCE for enhanced security.Installation
Setup
1. Create OAuth Credentials
- Go to Google Cloud Console
- Create a new project or select an existing one
- Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Web application
- Add your authorized redirect URIs:
- Development:
http://localhost:3000/api/auth/callback/google - Production:
https://yourdomain.com/api/auth/callback/google
- Development:
- Save your Client ID and Client Secret
2. Configure Environment Variables
Configuration
GoogleProviderConfig
OAuth 2.0 client ID from Google Cloud Console
OAuth 2.0 client secret from Google Cloud Console
The callback URL where users will be redirected after authentication
OAuth scopes to request. Defaults to
["openid", "email", "profile"]Usage
Custom Scopes
Request additional permissions from Google:Available Scopes
openid- OpenID Connect authenticationemail- User’s email addressprofile- User’s basic profile informationhttps://www.googleapis.com/auth/calendar.readonly- Read-only calendar accesshttps://www.googleapis.com/auth/drive.readonly- Read-only Drive access
Implementation Details
The Google provider is implemented in/home/daytona/workspace/source/packages/providers/google/src/index.ts:1:
User Profile
The provider returns the following user profile data:Google user ID (from
sub claim)User’s email address
User’s full name
URL to user’s profile picture
Whether the email has been verified by Google
Features
- Full OAuth 2.0 implementation
- PKCE support for enhanced security
- Automatic token refresh with
access_type: "offline" - Email verification status from Google
- Profile picture retrieval
The provider automatically requests
access_type: "offline" and prompt: "consent" to ensure a refresh token is always returned.Troubleshooting
Redirect URI Mismatch
Ensure the redirect URI in your code exactly matches one configured in Google Cloud Console, including the protocol (http/https) and trailing slashes.Missing Email
If the email is not returned, verify that theemail scope is included in your configuration.
Invalid Client Error
Double-check that yourGOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables are correctly set.