diff --git a/Examples.md b/Examples.md index c3a48a71..f6a790b1 100644 --- a/Examples.md +++ b/Examples.md @@ -1,6 +1,9 @@ # Examples using auth0.net -# Authentication +- [Authentication API](#authentication-api) +- [Management API](#management-api) + +# Authentication API - [1. Client Initialization](#1-client-initialization) - [2. Login With Client Credentials](#2-login-with-client-credentials) - [3. Authenticate using Resource Owner Password Grant Flow with MFA](#3-authenticate-using-resource-owner-password-grant-flow-with-mfa) @@ -170,3 +173,28 @@ await authClient.DeleteMfaAuthenticatorAsync( ``` ⬆️ [Go to Top](#) +# Management API + +## 1. Client Initialization + +To initialize the Management API client, you also need the Authentication API client to get the access token required by the Management API client constructor. + +```csharp +public async Task Initialize() +{ + var authClient = new AuthenticationApiClient("my.custom.domain"); + + // Fetch the access token using the Client Credentials. + var accessTokenResponse = await authClient.GetTokenAsync(new ClientCredentialsTokenRequest() + { + Audience = "audience", + ClientId = "clientId", + ClientSecret = "clientSecret", + }); + + managementClient = new ManagementApiClient(accessTokenResponse.AccessToken, "my.custom.domain"); +} +``` + +⬆️ [Go to Top](#) + diff --git a/README.md b/README.md index 801b9933..fb02a50a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ ## Documentation - [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0. +- [Examples](Examples.md) - code samples for common scenarios. ## Getting started @@ -38,6 +39,8 @@ The API calls are divided into groups which correlate to the [Management API doc await client.Connections.GetAllAsync("auth0"); ``` +See [more examples](Examples.md#management-api). + ### Authentication API #### Installation @@ -60,6 +63,8 @@ This library contains [URL Builders](https://auth0.github.io/auth0.net/#using-ur **Important note on state validation**: If you choose to use the [AuthorizationUrlBuilder](https://auth0.github.io/auth0.net/api/Auth0.AuthenticationApi.Builders.AuthorizationUrlBuilder.html) to construct the authorization URL and implement a login flow callback yourself, it is important to generate and store a state value (using [WithState](https://auth0.github.io/auth0.net/api/Auth0.AuthenticationApi.Builders.AuthorizationUrlBuilder.html#Auth0_AuthenticationApi_Builders_AuthorizationUrlBuilder_WithState_System_String_)) and validate it in your callback URL before exchanging the authorization code for the tokens. +See [more examples](Examples.md#authentication-api). + ## Feedback ### Contributing @@ -92,3 +97,4 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?
This project is licensed under the MIT license. See the LICENSE file for more info.
+