Endpoint
Authenticate users using Google OAuth via Firebase. This endpoint accepts a Firebase ID token and creates or logs in a user account.
This endpoint is rate limited to 5 requests per 15 minutes in production.
Request Body
Firebase ID token obtained from Google Sign-In on the client side
Response
JWT access token valid for 15 minutes
JWT refresh token valid for 7 days
User information
User first name (from Google profile)
User last name (from Google profile)
Always true for Google OAuth users
Google profile picture URL
Example Request
curl -X POST https://api.contafy.com/api/auth/google \
-H "Content-Type: application/json" \
-d '{
"idToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6..."
}'
Success Response
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"email": "[email protected]",
"nombre": "Juan",
"apellido": "Pérez",
"email_verified": true,
"logo_url": "https://lh3.googleusercontent.com/a/..."
}
}
Error Responses
400 Bad Request
{
"error": "Error de validación",
"details": [
{
"field": "idToken",
"message": "El idToken de Firebase es obligatorio"
}
]
}
401 Unauthorized
{
"error": "Token de Firebase inválido",
"message": "No se pudo verificar el token de Firebase"
}
429 Too Many Requests
{
"error": "Demasiados intentos de autenticación, por favor intenta nuevamente más tarde."
}
500 Internal Server Error
{
"error": "Error interno del servidor",
"message": "Error al procesar la autenticación con Google"
}
How It Works
- User signs in with Google on the client side using Firebase Authentication
- Client receives a Firebase ID token
- Client sends the ID token to this endpoint
- Server verifies the token with Firebase
- Server creates a new user account (if first login) or retrieves existing user
- Server automatically verifies the email (Google accounts are pre-verified)
- Server creates a FREE subscription for new users
- Server returns JWT tokens for API access
Google OAuth users have their email automatically verified and do not need to go through the email verification flow.
- Login - Standard email/password authentication
- Register - Create account with email/password
- Get Current User - Retrieve authenticated user information