google strategy to authenticate users with their Google accounts. This is a preset of the generic OAuth flow with Google’s endpoints pre-configured.
Creating a Google OAuth Client
- Go to the Google Cloud Console
- Select or create a project
- Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- For Application type, select Web application
- Configure the authorized redirect URI:
- For production:
https://your-domain.com/oauth/provider-callback - For local development:
http://localhost:3000/oauth/provider-callback
- For production:
- Copy the Client ID and Client Secret
Environment Setup
Preset Values
| Setting | Default |
|---|---|
| Accounts URL | https://accounts.google.com |
| Authorization URL | https://accounts.google.com/o/oauth2/v2/auth |
| Token URL | https://oauth2.googleapis.com/token |
| Default scopes | openid email profile |
OAUTH_* values.
Example: Google Sheets + Drive
Available Scopes
| Scope | Description |
|---|---|
https://www.googleapis.com/auth/spreadsheets | Read/write Google Sheets |
https://www.googleapis.com/auth/drive.readonly | Read Google Drive files |
https://www.googleapis.com/auth/drive | Full Google Drive access |
https://www.googleapis.com/auth/gmail.readonly | Read Gmail |
openid | OpenID Connect authentication |
email | Access email address |
profile | Access profile information |
Tool Context
WhenAUTH_STRATEGY=google, successful authentication populates the tool context with:
context.providerToken— the Google access tokencontext.resolvedHeaders—{ Authorization: "Bearer <google-access-token>" }context.provider— provider info object withaccessToken,refreshToken,expiresAt,scopescontext.authStrategy—"google"
Example Tool
Additional Options
Offline Access
To receive a refresh token (for long-lived access), addaccess_type=offline to extra auth params:
Force Consent
To force the consent screen to appear every time:Getting User Info
Usecontext.getUser() to fetch the authenticated user’s profile from Google:
getUser helper with USERINFO_ENDPOINTS:
USERINFO_ENDPOINTS constant provides pre-configured URLs:
| Provider | Endpoint |
|---|---|
google | https://www.googleapis.com/oauth2/v2/userinfo |
github | https://api.github.com/user |
Access Google ID Token Claims
When using Google OAuth, theid_token is automatically decoded and available via context.provider?.idTokenClaims:
email- User’s email addressname- User’s full namepicture- URL to user’s profile picturesub- User’s unique Google ID