Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding management api docs with some examples #5925

Merged
merged 78 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
69f1fcc
adding management api docs with some examples
alina-tincas Mar 7, 2024
b192c9f
Update 14/umbraco-cms/extending-cms/custom-swagger-api.md
alina-tincas Mar 7, 2024
2fad9a8
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 7, 2024
1fd25d7
added articles to summary
alina-tincas Mar 7, 2024
65e0d25
Delete 14/umbraco-cms/extending-cms/custom-swagger-api.md
alina-tincas Mar 7, 2024
945b94f
update to correct path
alina-tincas Mar 7, 2024
c93bfdc
Merge branch 'create-management-api-article' of https://github.com/um…
alina-tincas Mar 7, 2024
1b74f9e
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 8, 2024
e0cbbc4
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 8, 2024
6d17b4c
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 8, 2024
9deb125
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
f337aa3
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 8, 2024
0714c95
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 8, 2024
c54b7e8
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 8, 2024
319eb0f
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 8, 2024
4ea4b3b
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 8, 2024
32c5e39
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 8, 2024
21fb47e
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
2935e9f
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
a3ac136
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
6d73d7f
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
c0ec278
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
ca5cecb
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
3e763f0
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
02af0b9
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
b4725b5
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
a4e7950
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
cef709c
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
3ce751f
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
253a444
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
efa87ae
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
5cb2246
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
0ed863d
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
4db631a
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
70137b7
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
1b0e889
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
0f5210d
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
0212c89
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
d4868c4
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
b53231f
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
1448877
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 8, 2024
d768675
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 8, 2024
dcced66
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
45e7275
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
d557321
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
d8eee5d
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
36dc3df
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
439dc68
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
e4be3b4
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 11, 2024
0a38955
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
7bf45ff
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
bf11133
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
0fc90bc
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
27c6452
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
242b2b8
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
c4f0e78
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
9eccd0a
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 11, 2024
01d1003
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 11, 2024
b84ca45
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 11, 2024
2e51de1
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 11, 2024
544a62d
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 11, 2024
cf38e15
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 11, 2024
7574d3e
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 11, 2024
5cb13cf
update images
alina-tincas Mar 11, 2024
1599ea7
Applying feedback from Kenn
alina-tincas Mar 13, 2024
ade10f2
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 13, 2024
f63cae0
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 13, 2024
01de158
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 27, 2024
848a395
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 27, 2024
a4d80cb
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 27, 2024
7f51fcc
Update 14/umbraco-cms/reference/custom-swagger-api.md
alina-tincas Mar 27, 2024
70f869a
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 27, 2024
162d6fc
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 27, 2024
cf0b962
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 27, 2024
23cee13
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 27, 2024
df220e6
Update 14/umbraco-cms/reference/management-api/README.md
alina-tincas Mar 27, 2024
aa2c576
Update 14/umbraco-cms/reference/management-api/postman-setup-swagger.md
alina-tincas Mar 27, 2024
3237906
highlighted images
alina-tincas Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 218 additions & 0 deletions 14/umbraco-cms/extending-cms/custom-swagger-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
---
description: Example of a Custom API with Authorization and Swagger
---

# Custom API with Authorization and Swagger

This article covers how to create a Custom API controller that is protected by the backoffice authorization policy. It also advertises itself in Swagger docs with authorization UI enabled.

This example can be a starting point for creating a secure custom API in the Swagger documentation or using the API Controller. You can find other examples in the [API versioning and OpenAPI](../reference/api-versioning-and-openapi.md) article.

{% hint style="info" %}

Before following this guide familiarize yourself with the [Management API](../reference/management-api/README.md) article. There you can read more about the Swagger documentation and Authorization which will be used in this article.

{% endhint %}

1. In an Umbraco v14+ installation, create at the root of the project a new `.cs` file called `MyBackOfficeSecurityRequirementsOperationFilter`.

2. Then add the following code so that the new API shows in the Swagger documentation and Swagger UI:

{% code title="MyBackOfficeSecurityRequirementsOperationFilter.cs" lineNumbers="true" %}
```csharp
{
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using Umbraco.Cms.Api.Common.Attributes;
using Umbraco.Cms.Api.Common.Filters;
using Umbraco.Cms.Api.Management.OpenApi;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Web.Common.Authorization;

namespace Umbraco.Cms.Web.UI.New.Custom;

//Necessary code for the new API to show in the Swagger documentation and Swagger UI
public class MyBackOfficeSecurityRequirementsOperationFilter : BackOfficeSecurityRequirementsOperationFilterBase
{
protected override string ApiName => "my-api-v1";
}

public class MyConfigureSwaggerGenOptions : IConfigureOptions<SwaggerGenOptions>
{
public void Configure(SwaggerGenOptions options)
{
options.SwaggerDoc("my-api-v1", new OpenApiInfo { Title = "My API v1", Version = "1.0" });
options.OperationFilter<MyBackOfficeSecurityRequirementsOperationFilter>();
}
}

public class MyComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
=> builder.Services.ConfigureOptions<MyConfigureSwaggerGenOptions>();
}

//Creating the Controller
[ApiController]
[ApiVersion("1.0")]
[MapToApi("my-api-v1")]
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
[JsonOptionsName(Constants.JsonOptionsNames.BackOffice)]
[Route("api/v{version:apiVersion}/my")]
public class MyApiController : Controller
{
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;

public MyApiController(IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
=> _backOfficeSecurityAccessor = backOfficeSecurityAccessor;

[HttpGet("say-hello")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
public IActionResult SayHello()
{
IUser currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity?.CurrentUser
?? throw new InvalidOperationException("No backoffice user found");
return Ok($"Hello, {currentUser.Name}");
}
}
}
```
{% endcode %}

- The `BackOfficeSecurityRequirementsOperationFilter` enables back-office authentication for Swagger UI.

Check warning on line 90 in 14/umbraco-cms/extending-cms/custom-swagger-api.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [UmbracoDocs.UmbracoTerms] We prefer 'backoffice' over 'back-office.' Raw Output: {"message": "[UmbracoDocs.UmbracoTerms] We prefer 'backoffice' over 'back-office.'", "location": {"path": "14/umbraco-cms/extending-cms/custom-swagger-api.md", "range": {"start": {"line": 90, "column": 63}}}, "severity": "WARNING"}
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved
- `BackOfficeSecurityRequirementsOperationFilterBase` is an abstract base class that can be reused for custom APIs.

2. Add the ApiController to setup the logic behind the endpoint:

{% code title="MyBackOfficeSecurityRequirementsOperationFilter.cs" lineNumbers="true" %}
```csharp
{
...

//Creating the Controller
[ApiController]
[ApiVersion("1.0")]
[MapToApi("my-api-v1")]
[Authorize(Policy = "New" + AuthorizationPolicies.BackOfficeAccess)]
[JsonOptionsName(Constants.JsonOptionsNames.BackOffice)]
[Route("api/v{version:apiVersion}/my")]
public class MyApiController : Controller
{
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;

public MyApiController(IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
=> _backOfficeSecurityAccessor = backOfficeSecurityAccessor;

[HttpGet("say-hello")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
public IActionResult SayHello()
{
IUser currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity?.CurrentUser
?? throw new InvalidOperationException("No backoffice user found");
return Ok($"Hello, {currentUser.Name}");
}
}
}
```
{% endcode %}

<details>

<summary>See the entire file: MyBackOfficeSecurityRequirementsOperationFilter.cs</summary>

{% code title="MyBackOfficeSecurityRequirementsOperationFilter.cs" lineNumbers="true" %}
```csharp
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using Umbraco.Cms.Api.Common.Attributes;
using Umbraco.Cms.Api.Common.Filters;
using Umbraco.Cms.Api.Management.OpenApi;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Web.Common.Authorization;

namespace Umbraco.Cms.Web.UI.New.Custom;

//Necessary code for the new API to show in the Swagger documentation and Swagger UI
public class MyBackOfficeSecurityRequirementsOperationFilter : BackOfficeSecurityRequirementsOperationFilterBase
{
protected override string ApiName => "my-api-v1";
}

public class MyConfigureSwaggerGenOptions : IConfigureOptions<SwaggerGenOptions>
{
public void Configure(SwaggerGenOptions options)
{
options.SwaggerDoc("my-api-v1", new OpenApiInfo { Title = "My API v1", Version = "1.0" });
options.OperationFilter<MyBackOfficeSecurityRequirementsOperationFilter>();
}
}

public class MyComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
=> builder.Services.ConfigureOptions<MyConfigureSwaggerGenOptions>();
}

//Creating the Controller
[ApiController]
[ApiVersion("1.0")]
[MapToApi("my-api-v1")]
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
[JsonOptionsName(Constants.JsonOptionsNames.BackOffice)]
[Route("api/v{version:apiVersion}/my")]
public class MyApiController : Controller
{
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;

public MyApiController(IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
=> _backOfficeSecurityAccessor = backOfficeSecurityAccessor;

[HttpGet("say-hello")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
public IActionResult SayHello()
{
IUser currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity?.CurrentUser
?? throw new InvalidOperationException("No backoffice user found");
return Ok($"Hello, {currentUser.Name}");
}
}
```
{% endcode %}

</details>

3. Run the project and navigate to `{yourdomain}/umbraco/swagger`.
4. From **Select a definition** choose the swagger documentation we have created with the above code, called **My API v1**.

![Created Custom API in Swagger Documentation](./images/custom-api-swagger-example.png)

Here we can find the endpoint that we have created:

```http
GET /api/v1/my/say-hello
```

5. Authenticate via the **Authorize** button.

6. Once authenticated try out the endpoint via the **Try it out** button and then click on **Execute**:

![Trying out the endpoint](./images/custom-api-swagger-example-response.png)

Here we get the response we have setup via code: `"Hello, {{userName}}"`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions 14/umbraco-cms/reference/management-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
description: Get started with the Management API.
---

# Management API

The Management API delivers headless capabilities built directly into Umbraco. In comparison with the Content Delivery API, Management API allows you to interact with everything else from the backoffice apart from the content and media items. You can then receive responses in a JSON format and lets you preset them in different channels, using your preferred technology stack. This feature preserves the friendly editing experience of Umbraco, while also ensuring a performant delivery of content in a headless fashion. And with its different extension points, you can tailor this API to fit a broad range of requirements.

Check warning on line 7 in 14/umbraco-cms/reference/management-api/README.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). Raw Output: {"message": "[UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words).", "location": {"path": "14/umbraco-cms/reference/management-api/README.md", "range": {"start": {"line": 7, "column": 80}}}, "severity": "WARNING"}
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

The Management API can also be used for custom apps or workflows with OpenID Connect.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

{% hint style="info" %}
The Management API is a replacement for the backoffice controllers that were not restful.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved
{% endhint %}

## Swagger Documentation

Umbraco ships with Swagger to document the Management API. Swagger and the Swagger UI are based on [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/) and is available at `{yourdomain}/umbraco/swagger`. For security reasons, both are disabled in non-production environments.
Read more about Swagger in the [API versioning and OpenAPI](../api-versioning-and-openapi.md) article.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

From the Swagger documentation you can select a definition to navigate to Umbraco Management API or the Content Delivery API. You can also create a custom documentation in the swagger which you can read more about in the [Custom Swagger API with Authorization](../../extending-cms/custom-swagger-api.md) article.

![Umbraco Management API documentation in Swagger](../images/management-api-swagger.png)

In the Swagger Umbraco Management API you can find a collection of the available endpoints in this version of Umbraco. It also includes all the legacy APIs that are available for backward compatibility.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

## Authorization

The Management API endpoints are protected by the backoffice authorization policy and need an authentication token to interact with them.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

To setup the authorization, click on **Authorize** button:
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

![Umbraco Management API Authorize Button](../images/management-api-swagger-authorize-button.png)

Then a popup will appear with some setup information and login form for authorization:
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

alina-tincas marked this conversation as resolved.
Show resolved Hide resolved
![Umbraco Management API Authorize Login](../images/management-api-swagger-authorize-instructions.png)

The available integration for the authorization is done via a backoffice user with the integration of **OAuth2, authorizationCode with PKCE**. If you are working on a production environment, you will need to setup an OAuth2 integration with the following Umbraco Authentication specifications:

Check failure on line 38 in 14/umbraco-cms/reference/management-api/README.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [UmbracoDocs.Acronyms] ' PKCE' has no definition Raw Output: {"message": "[UmbracoDocs.Acronyms] ' PKCE' has no definition", "location": {"path": "14/umbraco-cms/reference/management-api/README.md", "range": {"start": {"line": 38, "column": 135}}}, "severity": "ERROR"}
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

**Authorization URL**

```http
{yourdomain}/umbraco/management/api/v1/security/back-office/authorize
```

**Token URL**

```http
{yourdomain}/umbraco/management/api/v1/security/back-office/token
```

**Flow**

```http
authorizationCode with PKCE
```

**client_id**

```http
umbraco-swagger
```

You can see an example of how to setup OAuth2 with Postman in the [Swagger Setup in Postman](./postman-setup-swagger) article.

## Test an Endpoint
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

In order to test a Management API endpoint, follow these steps: , authorize localhost then click on the first endpoint , execute check response 200- then click
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

1. Authenticate via the **Authorize** button. On a development environment you need only a `client_id` which has a default value of `umbraco-swagger` to login. Then click **Authorize** and you will be logged in:
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Authenticate via the **Authorize** button. On a development environment you need only a `client_id` which has a default value of `umbraco-swagger` to login. Then click **Authorize** and you will be logged in:
1. Authenticate via the **Authorize** button. Make sure you use `umbraco-swagger` as the `client_id`:

You will ever only need the client_id - the client_secret should always be left blank because of the chosen auth flow.


![Umbraco Management API when Authenticated](../images/management-api-swagger-authenticated.png)

2. Expand the first endpoint of **Audit Log** and click **Try it out**

![Umbraco Management API Endpoint - Try it Out Button](../images/management-api-try-it-out.png)

3. Then you will have the option to change the values of the **parameters**, however in this case let´s leave the default values as they are. Now click on **Execute** so we can get some data for our **Audit Log** endpoint.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved

![Umbraco Management API Endpoint - Execute - Response](../images/management-api-execute-response.png)

In the **Response Body** we get the details of the **Audit Log** that we have requested.

4. You can continue changing the default **parameters**, **clear** the query or **cancel** the trial of the endpoint.
alina-tincas marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading