CodeWorks.Auth0Provider 2.0.0

dotnet add package CodeWorks.Auth0Provider --version 2.0.0                
NuGet\Install-Package CodeWorks.Auth0Provider -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeWorks.Auth0Provider" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeWorks.Auth0Provider --version 2.0.0                
#r "nuget: CodeWorks.Auth0Provider, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodeWorks.Auth0Provider as a Cake Addin
#addin nuget:?package=CodeWorks.Auth0Provider&version=2.0.0

// Install CodeWorks.Auth0Provider as a Cake Tool
#tool nuget:?package=CodeWorks.Auth0Provider&version=2.0.0                

CodeWorks.Auth0Provider

dotnet add package CodeWorks.Auth0Provider

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<CodeWorks.Utils.Auth0Provider>();
}

UserInfoModel

Create you own UserInfo model and have the library extract and cast to your prefered class with generics.

Profile.cs

public class Profile
{
    public string Id { get; set; }  // Will be mapped to the id (uuid) from Auth0
    public string Name { get; set; }
    public string Email { get; set; }
    public string Picture { get; set; }
    public List<string> Roles { get; set; } = new List<string>(); // Will be mapped to the Roles from Auth0
    public List<string> Permissions { get; set; } = new List<string>(); // Will be mapped to the Permissions from Auth0
}

HttpContext

extract the UserInfo in your controllers via HttpContext

AccountController.cs

public class AccountController : ControllerBase
  {
    // Uses Dependency IOC 
    private readonly Auth0Provider _auth0Provider;

    public AccountController(Auth0Provider auth0Provider)
    {
      _auth0Provider = auth0Provider;
    }

    [HttpGet]
    [Authorize] // Works with native controls
    public async Task<ActionResult<Account>> Get()
    {
      try
      {
        // retrieves userInfo from Auth0 or CacheControl
        Account userInfo = await _auth0Provider.GetUserInfoAsync<Account>(HttpContext);
        return Ok(userInfo);
      }
      catch (Exception e)
      {
        return BadRequest(e.Message);
      }
    }
  }
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 1,349 10/16/2023
1.1.0 2,026 10/3/2022
1.0.3 1,288 10/22/2020
1.0.2 400 10/22/2020
1.0.1 422 10/22/2020
1.0.0 535 10/17/2020