Skip to content
Dashboard
Theme
Theme

Google OAuth callback of a directory source

GET /v1/directory_sources/oauth/google/callback: Google OAuth callback of a directory source.

View Markdown

GET /v1/directory_sources/oauth/google/callback

The redirect URI registered on the OhAuthCat Google OAuth clients (Connect Google). Consumes the state (single use, 30 minutes, bound to one environment and directory), exchanges the code at oauth2.googleapis.com with the PKCE verifier, and verifies the ID token (issuer accounts.google.com, audience the OhAuthCat client, Google’s keys, expiry). It requires a refresh token and every Admin SDK scope (Google lets the admin untick scopes), else directory_source_scope_missing; a personal Gmail account (no hd) answers directory_source_workspace_required; a user who cannot read the directory answers directory_source_admin_required. Then it stores the tokens sealed, saves the grant (company = the hd Workspace domain) and the source (customer my_customer, scheduling a sync) and redirects to return_url with ohauthcat_oauth (connected or error), directory_id and, on error, error_code. An expired, unused state (kept 24 hours past expiry) redirects with error_code=directory_source_oauth_expired and is used up. An unknown or already used state answers directory_source_oauth_state_invalid (400) without redirecting: an HTML page for a browser, JSON otherwise.

Scope
public
Auth
None
Since
1.0
  • code string

    Absent when Google reports an error.

    max length 2048

  • state string

    max length 256

  • error string

    Google’s error (RFC 6749 §4.1.2.1), e.g. access_denied.

    max length 256

  • OhAuthCat-Version string

    Minor version; defaults to the environment’s pin.

  • 302 Redirect to the start request’s return_url.
  • 400 <a href="/errors/directory_source_oauth_state_invalid/">directory_source_oauth_state_invalid</a>: the state is unknown, already used or malformed. A browser (Accept text/html) gets a short self-contained HTML page ("This link can’t be used") naming only the request ID; API clients get the JSON error. Error
  • 429 Code: rate_limited. Retry-After is set. Error
  • 503 Code: service_unavailable. Retry-After is set; writes are paused. Error
  • default Any other error, including internal_error. Every code is in the error catalogue. Error

Errors share one shape; see the error code catalogue.

curl -X GET \
"https://api.ohauthcat.com/v1/directory_sources/oauth/google/callback"