Auth0 Setup for Bloqs

This guide covers all steps required to configure Auth0 for Bloqs, including application creation, API setup, post-login actions, and updating your .NET configuration.


Create a New Application

  • Log in to your Auth0 Dashboard.

  • Navigate to Applications → Applications and click Create Application.

  • Enter details:

    • Name: Bloqs App

    • Application Type: Single Page Application (SPA)

  • Click Create.

Configure Application Settings

  • Allowed Callback URLs:

    https://localhost:5001/authentication/login-callback
  • Allowed Logout URLs:

    https://localhost:5001
  • Allowed Web Origins:

    https://localhost:5001
  • Enable Cross-Origin Authentication: Toggle ON


Create an API

  • Navigate to Applications → APIs.

  • Click Create API.

  • Enter details:

    • Name: Bloqs API

    • Identifier: https://bloqs.local/api

    • Signing Algorithm: RS256

  • Click Create


Add a Post-Login Action

  • Navigate to Actions → Triggers → Post Login.

  • Click + Add Action → Build Custom.

  • Name it Add Claims and add the following code:

exports.onExecutePostLogin = async (event, api) => {
  const user = event.user;

  // Add standard claims to the access token
  api.accessToken.setCustomClaim("email", user.email);
  api.accessToken.setCustomClaim("nickname", user.nickname);
  api.accessToken.setCustomClaim("name", user.name);
};
  • Click Deploy and ensure the action is connected to the Post-Login Flow.


Update .NET AppSettings

Update your .NET project appsettings.json to match your Auth0 configuration:

{
  "Auth0": {
    "Domain": "YOUR_AUTH0_DOMAIN",
    "ClientId": "YOUR_AUTH0_CLIENT_ID",
    "Audience": "https://bloqs.local/api"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}
  • Domain: From your Auth0 application settings.

  • ClientId: From your Auth0 SPA application.

  • Audience: Must match the API Identifier (https://bloqs.local/api).


Verify Setup

  • Run Bloqs locally: https://localhost:5001.

  • Log in using Auth0 credentials.

  • Check the access token to ensure the custom claims (email, nickname, name) are included.

Last updated