Google OAuth callback of a directory source
GET /v1/directory_sources/oauth/google/callback: Google OAuth callback of a directory source.
GET /
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
Query parameters
Section titled “Query parameters”
Absent when Google reports an error.codestringmax length 2048
statestringmax length 256
Google’s error (RFC 6749 §4.1.2.1), e.g.errorstringaccess_denied.max length 256
Headers
Section titled “Headers”
Minor version; defaults to the environment’s pin.OhAuthCat-Versionstring
Responses
Section titled “Responses”- 302 Redirect to the start request’s return_url.
- 400
<a href="/: 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. Errorerrors/ directory_source_oauth_state_invalid/ "> directory_source_oauth_state_invalid</ a> - 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"const response = await fetch("https://api.ohauthcat.com/v1/directory_sources/oauth/google/callback", { method: "GET",});const data = await response.json();import osimport requests
response = requests.get( "https://api.ohauthcat.com/v1/directory_sources/oauth/google/callback",)data = response.json()