Google Login
This guide explains how to implement Google Sign-In in the LAX application.
Request
Endpoint
- Method: POST
- URL:
/api/auth/social/google/login
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
Request Body
{
"token": "google_id_token",
"device_type": "android|ios|web",
"fcm_token": "firebase_cloud_messaging_token",
"device_id": "unique_device_identifier"
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | The ID token obtained from Google Sign-In |
| device_type | string | Yes | The type of device making the request |
| fcm_token | string | No | Firebase Cloud Messaging token for push notifications |
| device_id | string | Required with fcm_token | Unique identifier for the device |
Success Response
{
"success": true,
"message": "You have logged in successfully",
"data": {
"id": 13,
"name": "khalid",
"email": "admin@12.com",
"is_using_apple_private_relay_email": false,
"avatar": null,
"token": "93|MCYIcgaFQR1dlh8SBAAFD7EPR3fe3sWgGssmzYVpe7684615",
"is_app_rated": null,
"is_app_rated_reminder": null,
"is_subscribed": true
},
"status_code": 200
}
Error Responses
Login Error (422)
{
"success": false,
"message": "حدث خطأ أثناء تسجيل الدخول",
"data": null,
"status_code": 422
}
Account Not Found (404)
{
"success": false,
"message": "Account not found",
"data": null,
"status_code": 404
}
Invalid Token (422)
{
"success": false,
"message": "The token field is required",
"data": null,
"status_code": 422
}
Validation Error (422)
{
"success": false,
"message": "The selected device type is invalid",
"data": null,
"status_code": 422
}
Example Implementation Flow
- Initialize Google Sign-In in your application
- User clicks on Google Sign-In button
- Obtain Google ID token after successful sign-in
- Send token to
/api/auth/social/google/loginendpoint - Handle the response and store the API token