SolidX

Google OAuth

Guide to configuring Google OAuth authentication

Overview

This document provides a guide on how to configure and use Google OAuth authentication. The implementation allows users to sign in using their Google accounts.

Google Cloud Configuration

To use Google OAuth, you must create and configure an app on the Google Cloud Console.

1. Create a Google Cloud Project

  1. Go to the Google Cloud Console. Google Cloud Console project selector
  2. Click Select a Project and then New Project.
  3. Enter a project name and click Create.
  4. Wait for the project to be created and select it.

2. Enable Google People API

  1. In the Google Cloud Console, navigate to APIs & Services > Library.
  2. Search for "Google People API".
  3. Click on it and then click Enable.

3. Create OAuth Credentials

  1. Navigate to APIs & Services > Credentials.
  2. Click Create Credentials and select OAuth Client ID.
  3. If prompted, configure the OAuth consent screen by providing the required information (application name, support email, etc.) and save it.
  4. Inside OAuth Client ID setup, choose Web application as the application type.
  5. Add your authorized redirect URIs:
    • Development: http://localhost:3000/api/iam/google/connect/callback
    • Production: https://your-api-domain.com/api/iam/google/connect/callback
  6. Click Create.

4. Get Client ID and Client Secret

  1. After creation, a dialog will appear with your Client ID and Client Secret.
  2. Copy both values and store them securely.
  3. You can view Client IDs anytime in the OAuth 2.0 Client IDs section and create new client secrets as needed.

Configuration (Environment Variables)

Add the following environment variables to your .env file:

# Google OAuth Configuration
IAM_GOOGLE_OAUTH_CLIENT_ID=your-client-id
IAM_GOOGLE_OAUTH_CLIENT_SECRET=your-client-secret
IAM_GOOGLE_OAUTH_CALLBACK_URL=http://localhost:3000/api/iam/google/connect/callback
IAM_GOOGLE_OAUTH_REDIRECT_URL=http://localhost:3001/auth/initiate-google-oauth

Authentication Flow

Google OAuth authentication flow showing user sign-in, consent, callback authorization code, token exchange, and session creation

The user selects “Sign in with Google” in your application.

Your application redirects the user to Google's authorization page.

The user signs in to Google and grants the requested permissions.

Google redirects to the configured callback URL with an authorization code.

SolidX exchanges the authorization code with Google and retrieves the user's identity information.

SolidX establishes an authenticated session and redirects the user back to your application.