Setting Up Google Authentication with MatureStack

Follow this guide to integrate Google Authentication into your MatureStack application for seamless user sign-in and sign-up.

Prerequisites

  • A Google Cloud account (Google Cloud Console)
  • Access to your MatureStack environment for testing and deployment

Step 1: Set Up the Consent Screen

1. Log in to the Google Cloud Console and navigate to the **APIs & Services** > **OAuth consent screen**.

2. Choose the **External** option if your app is for public users, or **Internal** if it’s for your organization only.

3. Fill out the required fields, including the app name, support email, and developer contact email.

4. Add any required scopes, such as `email` and `profile`, to define the permissions your app will request.

5. Save and proceed to verification if necessary.

Step 2: Create OAuth 2.0 Credentials

1. Go to **APIs & Services** > **Credentials** and click **Create Credentials** > **OAuth 2.0 Client IDs**.

2. Select **Web application** as the application type.

3. Add the authorized redirect URIs:

https://yourdomain.com/auth/callback/google
http://localhost:3000/auth/callback/google

4. Once created, copy the **Client ID** and **Client Secret**.

Step 3: Configure Your Application

Add the following environment variables to your application:

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=your_google_callback_url

Replace the placeholders with your actual **Client ID**, **Client Secret**, and **Redirect URL**.

Best Practices

  • Secure your OAuth credentials and never expose them in your frontend code.
  • Use environment variables for storing sensitive information.
  • Validate tokens on the server side to prevent unauthorized access.
MatureStack LogoBuilt with MatureStack