Skip to content

.NET client for the Auth0 Authentication & Management APIs.

License

Notifications You must be signed in to change notification settings

dandenton/auth0.net

 
 

Repository files navigation

.NET client library for the Auth0

Build Status NuGet version

This is for clients that are either flagged as OIDC Conformant (under the OAuth tab in the client Advanced settings) or if you are triggering the OIDC-conformant pipeline by using the audience parameter when starting an authorization flow.

Management API

Full Documentation

Full documentation on how to use this library can be found here.

Installation

Install-Package Auth0.ManagementApi

Usage

Generate a token for the API calls you wish to make (see Access Tokens for the Management API). Create an instance of the ManagementApiClient class with the token and the API URL of your Auth0 instance:

var client = new ManagementApiClient("your token", new Uri("https://YOUR_AUTH0_DOMAIN/api/v2"));

The API calls are divided into groups which correlate to the Management API documentation. For example all Connection related methods can be found under the ManagementApiClient.Connections property. So to get a list of all database (Auth0) connections, you can make the following API call:

await client.Connections.GetAllAsync("auth0");

Authentication API

Installation

Install-Package Auth0.AuthenticationApi

Usage

To use the Authentication API, create a new instance of the AuthenticationApiClient class, passing in the URL of your Auth0 instance, e.g.:

var client = new AuthenticationApiClient(new Uri("https://YOUR_AUTH0_DOMAIN"));

Authentication

This library contains URL Builders which will assist you with constructing an authentication URL, but does not actually handle the authentication/authorization flow for you. It is suggested that you refer to the Quickstart tutorials for guidance on how to implement authentication for your specific platform.

Important note on state validation: If you choose to use the AuthorizationUrlBuilder to construct the authorization URL and implement a login flow callback yourself, it is important to generate and store a state value (using WithState) and validate it in your callback URL before exchanging the authorization code for the tokens.

Documentation

For more information about auth0 visit our documentation page.

Building

This project can be built on Windows, Linux or macOS. Ensure you have the .NET Core SDK installed. You can also use the code editor of your choice or a full-blown IDE such as Visual Studio or Jetbrains Rider.

The full set of libraries can be built by running build.ps1 (on Windows) or build.sh on macOS / Linux. This will do a full compilation as well as execute the unit tests. You can run the unit tests individually by using the dotnet test command (see docs).

Building for Release

Since this library also targets the full .NET Framework, you can currently only do a build for release on Windows.

  1. Ensure that you have updated the Major, Minor and Revision version numbers in /build/common.props for the new version.
  2. Also update the PackageReleaseNotes in the above-mentioned file with the release notes.
  3. Run build.ps1 and ensure that all the tests pass.
  4. Run the command build.ps1 -Target Pack. This will perform a full Release build and create NuGet packages (*.nupkg) in the /artifacts folder.
  5. Upload the NuGet packages to NuGet using the nuget push command.

Testing

To run the integration tests, create a file client-secrets.json in the tests\Auth0.ManagementApi.IntegrationTests directory.

Be aware that Auth0 enforces rate limits, if you are running integration tests against a free-tier Auth0 account you may get Global limit has been reached errors.

The content should take the following format.

{
  "AUTH0_AUTHENTICATION_API_URL": "yourdomain.auth0.com",
  "AUTH0_MANAGEMENT_API_URL": "yourdomain.auth0.com",
  "AUTH0_MANAGEMENT_API_CLIENT_ID": "your client id",
  "AUTH0_MANAGEMENT_API_CLIENT_SECRET": "your client sercet",
  "AUTH0_MANAGEMENT_API_AUDIENCE": "https://yourdomain.auth0.com/api/v2/"
}

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository's issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

About

.NET client for the Auth0 Authentication & Management APIs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 97.9%
  • PowerShell 1.5%
  • Shell 0.6%