Skip to content
Merged
Changes from all commits
Commits
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
62 changes: 43 additions & 19 deletions api-playground/mdx/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ You can add an authentication method to your mint.json to enable it on every pag

The page's authentication method will override mint.json if both are set.

### Bearer Token

<CodeGroup>

```json mint.json
Expand All @@ -19,7 +21,7 @@ The page's authentication method will override mint.json if both are set.
}
```

```md page metadata
```md Page Metadata
---
title: "Your page title"
authMethod: "bearer"
Expand All @@ -28,36 +30,58 @@ authMethod: "bearer"

</CodeGroup>

## Supported Authentication Methods

- bearer
- basic
- none

The "none" authentication method is useful to disable authentication on a specific endpoint after setting a default in mint.json.

## Authentication Name
### Basic Authentication

By default, basic authentication asks for username and password. However, basic authentication can use a different name for username and password. For example, you could have called it `user-id:user-key`.

You can set the name property in mint.json to override the default functionality. Use colons to separate each property you want to request.
<CodeGroup>

```json Custom username and password
```json mint.json
"api": {
"auth": {
"method": "basic",
"name": "user-id:user-key"
"method": "basic"
}
}
```

You can also request a single API key by excluding the colon.
```md Page Metadata
---
title: "Your page title"
authMethod: "basic"
---
```

</CodeGroup>

```json Custom username and password
### API Key

<CodeGroup>

```json mint.json
"api": {
"auth": {
"method": "key",
"name": "my-api-key"
"name": "x-api-key"
}
}
```

```md Page Metadata
---
title: "Your page title"
authMethod: "key"
---
```

</CodeGroup>

### None

The "none" authentication method is useful to disable authentication on a specific endpoint after setting a default in mint.json.

<CodeGroup>
```md Page Metadata
---
title: "Your page title"
authMethod: "none"
---
```
</CodeGroup>