Skip to content

Commit d0fbc53

Browse files
authored
Management API examples (#799)
2 parents 7153758 + 78829e0 commit d0fbc53

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

Examples.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Examples using auth0.net
22

3-
# Authentication
3+
- [Authentication API](#authentication-api)
4+
- [Management API](#management-api)
5+
6+
# Authentication API
47
- [1. Client Initialization](#1-client-initialization)
58
- [2. Login With Client Credentials](#2-login-with-client-credentials)
69
- [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(
170173
```
171174
⬆️ [Go to Top](#)
172175

176+
# Management API
177+
178+
## 1. Client Initialization
179+
180+
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.
181+
182+
```csharp
183+
public async Task Initialize()
184+
{
185+
var authClient = new AuthenticationApiClient("my.custom.domain");
186+
187+
// Fetch the access token using the Client Credentials.
188+
var accessTokenResponse = await authClient.GetTokenAsync(new ClientCredentialsTokenRequest()
189+
{
190+
Audience = "audience",
191+
ClientId = "clientId",
192+
ClientSecret = "clientSecret",
193+
});
194+
195+
managementClient = new ManagementApiClient(accessTokenResponse.AccessToken, "my.custom.domain");
196+
}
197+
```
198+
199+
⬆️ [Go to Top](#)
200+

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
## Documentation
1111

1212
- [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.
13+
- [Examples](Examples.md) - code samples for common scenarios.
1314

1415
## Getting started
1516

@@ -38,6 +39,8 @@ The API calls are divided into groups which correlate to the [Management API doc
3839
await client.Connections.GetAllAsync("auth0");
3940
```
4041

42+
See [more examples](Examples.md#management-api).
43+
4144
### Authentication API
4245

4346
#### Installation
@@ -60,6 +63,8 @@ This library contains [URL Builders](https://auth0.github.io/auth0.net/#using-ur
6063

6164
**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.
6265

66+
See [more examples](Examples.md#authentication-api).
67+
6368
## Feedback
6469

6570
### Contributing
@@ -92,3 +97,4 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
9297
<p align="center">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a></p>
9398
<p align="center">
9499
This project is licensed under the MIT license. See the <a href="./LICENSE"> LICENSE</a> file for more info.</p>
100+

0 commit comments

Comments
 (0)