Improve Google Android login error diagnostics.

Preserve the underlying Google token validation failure and log safe request context so ID token issues are easier to debug.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-05-26 06:32:15 -07:00
parent 79fb95ce36
commit d3225ca61a
2 changed files with 6 additions and 1 deletions

View File

@ -106,7 +106,7 @@ func (s *Service) LoginWithGoogleAndroid(
payload, err := idtoken.Validate(ctx, idToken, clientID) payload, err := idtoken.Validate(ctx, idToken, clientID)
if err != nil { if err != nil {
return domain.LoginSuccess{}, errors.New("invalid google id token") return domain.LoginSuccess{}, fmt.Errorf("invalid google id token: %w", err)
} }
email, _ := payload.Claims["email"].(string) email, _ := payload.Claims["email"].(string)

View File

@ -51,6 +51,11 @@ func (h *Handler) GoogleAndroidLogin(c *fiber.Ctx) error {
loginRes, err := h.authSvc.LoginWithGoogleAndroid(c.Context(), req.IDToken, h.Cfg.GoogleOAuthClientID) loginRes, err := h.authSvc.LoginWithGoogleAndroid(c.Context(), req.IDToken, h.Cfg.GoogleOAuthClientID)
if err != nil { if err != nil {
h.mongoLoggerSvc.Error("Google Android login failed",
zap.Error(err),
zap.Int("id_token_length", len(req.IDToken)),
zap.Bool("google_client_id_configured", h.Cfg.GoogleOAuthClientID != ""),
)
return c.Status(fiber.StatusUnauthorized).JSON(domain.ErrorResponse{ return c.Status(fiber.StatusUnauthorized).JSON(domain.ErrorResponse{
Message: "Google login failed", Message: "Google login failed",
Error: err.Error(), Error: err.Error(),