Skip to Content
HomeLink Hub
Authentication

Sign in with a Google ID token (mobile)

POST
/api/v1/auth/google/native

Access: Public, no token needed.

Native Google Sign-In for the mobile app. Verifies the ID token against the server's configured Google client IDs, then signs the user in and returns the same body as POST /auth/signin. There is no request validation schema on this route; the handler checks only that idToken is a non-empty string.

The account is matched by Google ID first, then by email. An existing account with the same email gets Google linked, is marked email-verified and has its avatar replaced by the Google picture. Otherwise a new account is created, already email-verified and with no password, with the requested role (TENANT or AGENT; anything else becomes TENANT). New AGENT accounts start with a PENDING KYC record. role is ignored for existing accounts. 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).

This handler does not check whether the account is active. An ID token that fails verification (bad signature, wrong audience, expired) is answered with a 500 whose message is the Google library's own text.

Request Body

application/json
  1. body
idToken*string

The ID token returned by the Google Sign-In SDK on the device.

role?string

Account type to create if this Google account is new: TENANT (default) or AGENT. Any other value is treated as TENANT. Ignored when the account already exists.

Response Body

Signed in (existing, newly linked or newly created account)

application/json
  1. response
status*integer
success*boolean
message*string
data*
Example Request
curl -X POST 'http://localhost:4000/api/v1/auth/google/native' \  -H 'Content-Type: application/json' \  -d '{  "idToken": "eyJhbGciOiJSUzI1NiIs...",  "role": "TENANT"}'
Example Response
{  "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    }  }}