RouteCab Online
A B
Select a route A → B
Point A Point B
Saved Routes
0 / 5
Active
0 live
A → B Distance
—

Google Authentication

Sign in via Google GIS Callback or Telegram Mini App

Enter a Google Client ID above or use the simulated Google Callback below for local testing.

Telegram Mini App (TMA) URL Auth POST /auth/tma

Auto-decodes `#tgWebAppData` / `?user=` URL on entry, skips hash locally, and adds user to MongoDB if missing.

Google OAuth 2.0 & Web Callbacks Setup Guide

Step-by-step configuration for Google Cloud Console & Go Server

1. Create OAuth 2.0 Client ID in Google Cloud Console

Go to Google Cloud Console → APIs & Services → Credentials → Create Credentials → OAuth client ID (Web application).

Authorized JavaScript origins:
• http://localhost:4000
• https://your-domain.example
Authorized redirect URIs (Web Callbacks):
• http://localhost:4000/auth/google/callback
• https://your-domain.example/auth/google/callback

2. Configure Environment Variables (`.env`)

Set your Client ID and JWT secret in `.env` before starting the Go server:

GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
JWT_SECRET=your-production-jwt-secret
PORT=4000
DEV=0

3. How Web Callbacks Work (JS Callback + HTTP Redirect Callback)

  • JS Popup Callback (`window.handleGoogleCredentialResponse`): Google Identity Services invokes this callback with `{ credential }` (ID Token) and sends `POST /auth/google` to receive a signed Bearer JWT.
  • Redirect URI Callback (`POST/GET /auth/google/callback`): Receives `credential` form/query payload from Google OAuth redirect, verifies the token on the Go server, and redirects to `/?jwt=...` where the web app automatically logs in.