SolidX

Microsoft OAuth

Guide to configuring Microsoft OAuth authentication

Overview

This document provides a guide on how to configure and use Microsoft OAuth authentication. The implementation uses Microsoft Entra ID (formerly Azure Active Directory) to allow users to sign in with their Microsoft accounts.

Microsoft Entra ID Configuration (Azure Portal)

To use Microsoft OAuth, you must register an application in the Microsoft Entra admin center.

1. Register an Application

  1. Log in to the Microsoft Entra admin center (formerly Azure Portal). Microsoft for Developers Landing Page
  2. Click on App registrations.
  3. Click New registration.
  4. Enter a name for your application (e.g., SolidCore-App). Microsoft for Developers Landing Page
  5. Choose the Supported account types (e.g., "Any Entra ID Tenant + Personal Microsoft accounts").
  6. In the Redirect URI section, select Web and enter your callback URL:
    • Development: http://localhost:3000/api/iam/microsoft/connect/callback
    • Production: https://your-api-domain.com/api/iam/microsoft/connect/callback
  7. Click Register.

2. Get Application and Tenant IDs

  1. After registration, you will be on the application's Overview page.
  2. Copy the Application (client) ID.
  3. Copy the Directory (tenant) ID.

3. Create a Client Secret

  1. Navigate to Certificates & secrets > Client secrets.
  2. Click New client secret.
  3. Add a description and set an expiration time.
  4. Click Add.
  5. IMPORTANT: Copy the secret Value immediately. You will not be able to see it again.

Configuration (Environment Variables)

Add the following environment variables to your .env file:

# Microsoft OAuth Configuration
IAM_MICROSOFT_OAUTH_CLIENT_ID=your-application-id
IAM_MICROSOFT_OAUTH_CLIENT_SECRET=your-client-secret
IAM_MICROSOFT_OAUTH_TENANT_ID=your-tenant-id
IAM_MICROSOFT_OAUTH_CALLBACK_URL=http://localhost:3000/api/iam/microsoft/connect/callback
IAM_MICROSOFT_OAUTH_REDIRECT_URL=http://localhost:3001/auth/initiate-microsoft-oauth

Authentication Flow

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

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

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

The user signs in with Microsoft and grants the requested permissions.

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

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

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