# Authentication

### Arrange Data

First, you need to arrange data which will be used to generate message

```json
{
    "owner": "string" // can be address or DID
}
```

### Generate a message

{% openapi src="<https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5>" path="/authentication/generate-message" method="post" %}
[openapi.yml](https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media\&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5)
{% endopenapi %}

### Generate Access Tokens

Sign the above message using the appropriate address and arrange data in below format

```json
{
    "owner": "string",
    "signature": "string",
    "timestamp": "number"
}
```

`signature` is the obtained by signing the above generated message and timestamp is also given in the response of [this](#generate-a-message)

`timestamp` can't be older than 5 minutes

{% openapi src="<https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5>" path="/authentication" method="post" %}
[openapi.yml](https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media\&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5)
{% endopenapi %}

### Authenticate

To authenticate, just include the received `accessToken` in `headers` as `authorization` in format `bearer ${accessToken}`
