Skip to Content
HomeLink Hub
Calendar

Google Calendar OAuth callback

GET
/api/v1/calendar/google/callback

Access: Public, no token needed. Also requires: A valid signed state from GET /calendar/google/url.

Redirect target that Google sends the browser to after the consent screen; clients never call it directly. It takes no bearer token: the user is identified by the signed state query parameter issued by GET /calendar/google/url (a JWT signed with a dedicated server-side secret, valid for 10 minutes).

On success the handler exchanges code for tokens, stores the refresh token encrypted (AES-256-GCM) on the user, back-fills Google Calendar events for the user's paid, upcoming, not-yet-synced inspections in the background, and answers with a 302 redirect to <FRONTEND_URL><returnPath>?calendar=connected. It redirects with ?calendar=error instead when code is absent (the user declined), Google returns no refresh token, the calendar scope was not granted, or the token exchange fails. A JSON error is returned only when state is unusable or the feature is not configured.

Query Parameters

code?string

Authorization code appended by Google. Absent when the user declined consent.

state*string

Signed state token from the consent URL; identifies the user and the return path.

Response Body

Always a redirect when state is valid; there is no JSON body. Location is <FRONTEND_URL><returnPath>?calendar=connected on success or ...?calendar=error on any Google-side failure, where FRONTEND_URL is the web app origin configured on the server and returnPath defaults to /app/inspections.

Example Request
curl -X GET 'http://localhost:4000/api/v1/calendar/google/callback?state=string'
Example Response
Empty