Complete Google sign-in with an authorisation code
Access: Public, no token needed.
Exchanges the authorisation code from Google's redirect for the user's Google profile, then signs the user in. Returns JSON in the same shape as POST /auth/signin; it does not redirect, so the frontend page that receives Google's redirect must call it with the code and state.
The account is matched by Google ID first, then by email. An existing account with the same email gets Google linked to it, is marked email-verified and has its avatar replaced by the Google picture. If no account exists, a new TENANT account is created, already email-verified, with no password. A session record is stored for the device (device name and browser are derived from the User-Agent header, location is the first X-Forwarded-For address or the request IP); only the 10 most recent sessions are kept. The account holds one refresh token, so signing in overwrites the previous one and refresh tokens issued to other devices stop working. If the account already had at least one session, a new_device_login notification ("New Login Detected") is created: it is delivered over the notifications:new socket event and as a push only if the user's systemUpdates.inApp preference is on (off by default), and by email if systemUpdates.email is on (on by default).
Unlike password and Apple sign-in, this handler does not check whether the account is active. If Google rejects the code (already used, expired, wrong redirect URI) the error from the Google client library is passed through; the response uses the HTTP status Google answered with and the library's message (for example invalid_grant), so treat any non-200 here as a failed sign-in rather than matching on a fixed message.
code*stringThe one-time authorisation code Google appended to the redirect URI.
state?stringThe state value Google returned. app selects the client-app OAuth client; anything else (normally web) selects the consumer web app. Must match the client used to start the flow.
Signed in (existing, newly linked or newly created account)
application/json- response
status*integersuccess*booleanmessage*stringdata*curl -X GET 'http://localhost:4000/api/v1/auth/google/callback?code=string'{ "status": 200, "success": true, "message": "Google sign-in successful.", "data": { "accessToken": "eyJhbGciOiJIUzI1NiIs...", "refreshToken": "eyJhbGciOiJIUzI1NiIs...", "user": { "id": "665f1c2e9b1d4a0012ab34cd", "firstName": "Adaeze", "lastName": "Okonkwo", "email": "adaeze.okonkwo@gmail.com", "avatar": "https://lh3.googleusercontent.com/a/ACg8ocK...=s96-c", "role": "TENANT", "isKYCVerified": false } }}
HomeLink Hub