Blazor with Auth0, using the Management API

  1. Blazor Authentication with Auth0
  2. Blazor Authorization with Auth0
  3. Blazor With Auth0, using the Management API (this one)
  • Creating roles using the Auth0 dashboard
  • Assigning roles to your users using theAuth0 dashboard
  • Protect certain endpoints only for users within a specified role.
  • Using the Management API to query all our users/roles stored in Auth0.
  • Create a new Role using the Management API.
  • Using the API Explorer to test certain endpoints of the Management API.
  • Upgrade our API to a Machine to Machine (M2M) client to use the management API.
  • Automatically re-use the access token leveraging Dependency Injection and Delegation Handlers
  • As a Administrator I want to see all the users stored in the Auth0 database in the Blazor Client (not in the Auth0 dashboard)
  • Login as administrator within Auth0.
  • See all users stored in the Blazor client instead of the Auth0 dashboard.

The Auth0 Dashboard

API Explorer, Swagger’s bigger brother.

  1. Navigate to the dashboard.
  2. Click on Applications > APIs in the sidebar
  3. Select the Auth0 Management API
  4. Click on the API Explorer tab
  5. Navigate to the Auth0 API Explorer
  6. Copy the Access Token
  1. Go to the Management API Explorer.
  2. Click the Set API Token button at the top left.
  3. Set the API token by pasting the API Token that you copied in the previous step.
  4. Click the Set Token button.
  5. Scroll down to Users > List or Search Users
  6. Scroll down and click Try , you’ll see all the users in the database

Showing all users in our Blazor Application

Machine to Machine Communication (M2M)

  1. Navigate to the Auth0 Dashboard
  2. Click Applications
  3. Click Create Application
  4. Give a fancy name for the Application API To Management API in our case
  5. Select Machine To Machine Applications
  6. Click Create Application
  7. Select Auth0 Management API
  8. Select All Permissions
  9. Click Authorize
  10. Copy-paste the ClientId and ClientSecret, we’ll need it in just a moment

Integration with C# and Blazor

  1. Call the API to request a new access token and then make our request.
  2. Implement our own access token cache to re-use tokens as much as possible so each request can use the token without requesting a new access token, which might be bad for performance and totally unnecessary!
dotnet add package Auth0Net.DependencyInjection





Turning coffee into code.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

LENOVO THINKPAD — X390 — CORE i5–8365U — 1.60GHz — SSD NVME 256GB -

Set your own reminders in Ubuntu in 2 minutes

Top 10 App application development companies in India

Is this the one use case where a multi-cloud architecture actually makes sense?

CS 373 Spring 2021 Week 8: Melanie De La Cruz

Development and deployment of a website using ReactJS, Flask, PIL, Moviepy and more (Part I)

Meet Our Ambassador- Zainab Jimoh

Alvin’s Dew Drop Daily — Issue #83

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Benjamin Vertonghen

Benjamin Vertonghen

Turning coffee into code.

More from Medium

Build a Placeholder API With the New ASP.NET Core Minimal API

Release the limits of Github Actions with self-hosted runners

Web Apps with Razor Pages

Exploring hosting startup assemblies in ASP.NET Core