# App Authentication

Do not require authentication:

* [Resolver API](/api/resolver-api.md)

Do require authentication:

* [Kernel Account API](/api/kernel-account-api.md)

Authenticated Patch API endpoints use [OAuth 2.0 methods](https://oauth.net/2/) to authenticate requests.

**Get Started**

1. On [Discord](https://discord.gg/EAFPKSRyth), request a `client_id` and `client_secret`
2. Request a Bearer token via the `/v1/auth` endpoint
3. Provide the Bearer token in the `Authorization` header

### 1) Get a client\_id and client\_secret

On [Discord](https://discord.gg/EAFPKSRyth) request a `client_id` and `client_secret` to access the service.

### 2) Request a Bearer token

Use the script below to get a Bearer token for your `client_id` and `client_secret`.

```javascript
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("client_id", "demo-user-external");
urlencoded.append("client_secret", "k^yf57yg27MKo2SnuzwX");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://paymagicapi.com/v1/auth", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### 3) Call endpoints with Bearer token

API requests are authenticated using the [Bearer Auth scheme](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes). To authenticate a request, provide the Bearer token in the `Authorization` header of the request:

```bash
curl -H "Authorization: Bearer <your_bearer_token>" https://paymagicapi.com/v1
```

Bearer tokens expire every 60 minutes so a new one needs to be generated.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.patchwallet.com/api/app-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
