canonical: https://jentic.com/apis/googleapis.com/oauth2

# Google OAuth2 API

The Google OAuth2 API surfaces the lightweight identity endpoints that complement the broader Google OAuth 2.0 token flow - the userinfo endpoint that returns profile claims for an authenticated user, and the tokeninfo endpoint that introspects a Google-issued access or ID token. Use it after a sign-in flow to retrieve a user's basic profile (email, name, picture, locale) or to validate that a token is still active and was issued for the expected client. The spec exposes 3 endpoints.

## For AI agents

Fetch authenticated Google user profile data and introspect Google-issued OAuth tokens through the OAuth2 userinfo and tokeninfo endpoints.

## Scope

Does not mint or refresh tokens, manage Google accounts, or grant scopes - use for reading profile claims and introspecting existing tokens only.

## Capabilities

- Fetch the authenticated user's profile claims via the userinfo endpoint
- Introspect a Google access or ID token to verify it is still active
- Confirm the audience and scopes attached to a Google-issued token
- Resolve a Google account email and verified email status from a session token
- Pull the user's locale and profile picture URL for personalised UX

## Use cases

### Sign in with Google profile retrieval

After completing the Google OAuth 2.0 authorization code or implicit flow, call the userinfo endpoint with the resulting access token to retrieve the authenticated user's email, name, locale, and profile picture. This is the canonical step for application onboarding flows that bootstrap a user record from Google identity. The endpoint accepts the bearer token and returns a small JSON document with verified profile claims.

Example prompt: After exchanging an authorization code for an access token, call GET /oauth2/v2/userinfo with the bearer token and extract the email, name, and verified_email fields.

### Token validation before privileged actions

Before executing a sensitive action on behalf of a user, validate that the cached Google access token is still active and was issued to the expected client by calling tokeninfo. This catches revoked tokens and audience mismatches before they hit a downstream Google API and surface as opaque 401s. Useful for backend services that store long-lived tokens and replay them.

Example prompt: POST to /oauth2/v2/tokeninfo with access_token=ya29.xxx and reject the request if the response audience field does not match the expected client_id.

### Locale-aware personalisation

Read the user's locale from the userinfo response and use it to pick the correct localisation bundle, currency format, and date format for the UI. This avoids the common pitfall of hard-coding en-US for users whose Google account is set to another locale. The locale field comes through as a BCP-47 tag.

Example prompt: Call GET /oauth2/v2/userinfo, read the locale field, and load the matching i18n bundle for the user's session.

### Agent-driven Google identity checks via Jentic

An AI agent that needs to confirm a user's Google identity before taking action can use Jentic to call userinfo or tokeninfo without holding raw tokens. The Jentic One instance stores the user's refresh token and mints a scoped access token only for the call. Useful for assistant agents that need to confirm identity before surfacing sensitive content.

Example prompt: Use Jentic to find the get-user-info operation, load its schema, and execute it for the current session to confirm the user's verified email.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /oauth2/v2/userinfo | Get the authenticated user's profile |
| POST | /oauth2/v2/tokeninfo | Introspect a Google access or ID token |
| GET | /userinfo/v2/me | Alias for the authenticated user's profile |

## Key resources

- **userinfo** — Authenticated user's profile claims
- **tokeninfo** — Token introspection for Google-issued access and ID tokens

## Why Jentic

- **Setup:** Wiring the Google OAuth2 API by hand means configuring OAuth 2.0, minting scoped access tokens, and routing profile and token-introspection reads to the right www.googleapis.com paths yourself. Through Jentic you install once, import the Google OAuth2 API from the API Directory, store the OAuth credential once, and your agent calls it.
- **Permission scoping:** The Google OAuth2 API exposes fixed read endpoints (/oauth2/v2/userinfo, /oauth2/v2/tokeninfo), so limit the agent to the operations it needs, such as reading the user profile or introspecting a token. Every operation the agent can call is one you added to the allowed set, and these are read-only claims and token checks.
- **Credential handling:** Your Google OAuth credential for the OAuth2 API is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'get the Google user profile' or 'validate a Google token', and Jentic returns the matching OAuth2 API operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **People API** — People API returns richer contact and profile data beyond the OAuth2 userinfo claims
- **Cloud Identity API** — Cloud Identity owns directory and group membership data beyond what userinfo returns
- **Identity and Access Management API** — IAM handles service-account identity instead of end-user identity

## FAQ

### What authentication does the Google OAuth2 API use?

The userinfo endpoint requires a Google OAuth 2.0 bearer token with the userinfo.profile and/or userinfo.email scope. tokeninfo accepts a token as a query parameter and does not need its own bearer credential. Through Jentic, tokens are minted from a refresh credential held in your Jentic One instance.

### Can I get the user's email through this API?

Yes - call GET /oauth2/v2/userinfo with a token that includes the email scope and the response will include the email and verified_email fields.

### What are the rate limits for the OAuth2 API?

Google does not publish a hard quota for these endpoints; treat them as cheap but not free, cache userinfo responses for the session, and avoid calling tokeninfo on every request - call it only when you need to revalidate a stored token.

### How do I introspect a token through Jentic?

Search Jentic for token introspection google, load the schema for POST /oauth2/v2/tokeninfo, and execute it with the token to introspect. Jentic returns the audience, scopes, and expiry so the agent can decide whether to proceed.

### Does this API mint new access tokens?

No - token minting and refresh happen at https://oauth2.googleapis.com/token, which is part of the broader Google OAuth 2.0 flow and not in this spec. This API only reads profile claims and introspects existing tokens.

### What's the difference between userinfo and tokeninfo?

userinfo returns claims about the user (email, name, picture) and requires a bearer token in the Authorization header. tokeninfo returns claims about the token itself (audience, scope, expiry) and takes the token as a parameter.

### Can I limit what my agent is allowed to do with the Google OAuth2 API?

Yes. Because you self-host your own Jentic One instance, your rules decide which of this API's operations the agent may call, and it can only use the credential and endpoints you add to its allowed set. The Google OAuth2 API exposes fixed read endpoints, so you can permit reading the signed-in user's profile at /oauth2/v2/userinfo while withholding token introspection at /oauth2/v2/tokeninfo, or allow both. Every one of these is a read-only profile-claim or token-check call, and the stored Google credential is injected only at execution time.
