Google sign-in
The API always registers Google as a sign-in provider; it works once
OAUTH_GOOGLE_CLIENT_ID and OAUTH_GOOGLE_CLIENT_SECRET are set. The auth
screens in both front-end templates already have the button.
-
In the Google Cloud console, configure the OAuth consent screen (app name, support email, your domains).
-
Create credentials → OAuth client ID, type Web application:
- Authorised JavaScript origins: each front end’s origin
(
https://app.example.com;http://localhost:3000for development). - Authorised redirect URIs:
<BETTER_AUTH_URL>/auth/callback/google, e.g.https://api.example.com/auth/callback/googleandhttp://localhost:5000/auth/callback/google.
- Authorised JavaScript origins: each front end’s origin
(
-
Copy the client id and secret into the API’s
OAUTH_GOOGLE_CLIENT_IDandOAUTH_GOOGLE_CLIENT_SECRET.
The API asks for email and profile, with offline access. After Google, the
browser returns to the callbackURL the front end passed, which must be one of
the API’s trusted origins.