Google OAuth setup for Authverse projects
This page details how to add and configure Google OAuth for Authverse projects.
Execute the following command to add the Google provider to your project:
npx authverse@latest add googleNavigate to the Google Cloud Console (APIs & Services → Credentials) and configure the Authorized Redirect URIs for your OAuth 2.0 Client ID:
http://localhost:3000/api/auth/callback/googlehttps://example.com/api/auth/callback/google[!NOTE] If you modify your auth base path (default:
/api/auth), ensure these redirect URIs are updated to match.
Add the following variables to your project's .env file:
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=Replace the values with the Client ID and Client Secret obtained from the Google Cloud Console.
[!TIP] Adjust this configuration to use your preferred method for securely storing secrets in CI/CD pipelines.
Import the prebuilt provider component and integrate it into your UI:
import GoogleProviders from "@/components/authverse/GoogleProviders";
<GoogleProviders />;This component renders the Google sign-in option at its location.
https://example.com with your authenticated domain.