# Auth

{% hint style="info" %}
**Requirement** You are required to show empowered by RE:DREAMER if you used our protocol in any part of your product.
{% endhint %}

![empowered white](/files/gEjvXfdl8K6iMeRwUzvz) ![empowered black](/files/mYCm6o8AEPxDKrp5SI9G)

## Domain

* Mainnet: `mainnet-api.redreamer.io`
* Testnet: `testnet-api.redreamer.io`

## GET /api/v1/auth/nonce

Get a nonce by given address.

### Request Parameters

* \[Required] `address`: the address of user.

### Response

#### 200

```json
{
   "nonce": "72452fa3-dbc6-44ae-8108-1dfb7edc1582"
}
```

#### 400, 500

```json
{
	"code": "ERROR_CODE"
}
```

#### Error Code

*

## POST /api/v1/auth/login

Login to get JWT.

### Request Body

```json
{
    "address": "0xb88b0776c6147d4da3056a16b20c2ddbdfb37275",
    "signature": "0x8217b11a64c4f8ee2ef01cd46fea87bf5ea65a4c6907e303f6c11d5e5fd2441a6e5daf05e8a98af42efafd6824010d7dd6bdfe9bb35c128636f1db9ded35ddda1c"
}
```

* `signature`: using `${address} ${nonce}` to sign message.

### Response

#### 200

```json
{
   "refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHg4NWI3Y2ExNjFjMzExZDlhNWYwMDc3ZDUwNDhjYWRmYWNlODlhMjY3IiwiZXhwIjoxNjUwNDMzNzY4LCJpYXQiOjE2NTAzNDczNjgsImlzcyI6InJlZHJlYW1lciIsInNjb3BlcyI6IiJ9.sMMuM0bCJjHs7DedWZd8w-2BWzovuBuCxgZwMW20TIwKSkrkue2T-9ecgW-8_TCsGoleiQa6DSDbQKq3_kQmjA",
   "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHg4NWI3Y2ExNjFjMzExZDlhNWYwMDc3ZDUwNDhjYWRmYWNlODlhMjY3IiwiZXhwIjoxNjUwMzUwOTY4LCJpYXQiOjE2NTAzNDczNjgsImlzcyI6InJlZHJlYW1lciIsInNjb3BlcyI6IiJ9.WWjCMbpWkpbzQulgqOQz5JqnC1lTEFG2_CTeFW21A8q7AKeEI_l2_ptqiG7lpcOCmojFW_3Zi3VAimO1k214cw"
}
```

* `token`: It will be expired after 1 hour.
* `refresh_token`: If token is expired, you can use this to refresh without signature.

#### 400, 500

```json
{
	"code": "ERROR_CODE"
}
```

#### Error Code

*

## POST /api/v1/auth/refresh

Refresh JWT.

### Request Body

```json
{
	"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHg4NWI3Y2ExNjFjMzExZDlhNWYwMDc3ZDUwNDhjYWRmYWNlODlhMjY3IiwiZXhwIjoxNjUwNDMzNzY4LCJpYXQiOjE2NTAzNDczNjgsImlzcyI6InJlZHJlYW1lciIsInNjb3BlcyI6IiJ9.sMMuM0bCJjHs7DedWZd8w-2BWzovuBuCxgZwMW20TIwKSkrkue2T-9ecgW-8_TCsGoleiQa6DSDbQKq3_kQmjA"
}
```

### Response

#### 200

```json
{
   "refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHg4NWI3Y2ExNjFjMzExZDlhNWYwMDc3ZDUwNDhjYWRmYWNlODlhMjY3IiwiZXhwIjoxNjUwNDMzNzY4LCJpYXQiOjE2NTAzNDczNjgsImlzcyI6InJlZHJlYW1lciIsInNjb3BlcyI6IiJ9.sMMuM0bCJjHs7DedWZd8w-2BWzovuBuCxgZwMW20TIwKSkrkue2T-9ecgW-8_TCsGoleiQa6DSDbQKq3_kQmjA",
   "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHg4NWI3Y2ExNjFjMzExZDlhNWYwMDc3ZDUwNDhjYWRmYWNlODlhMjY3IiwiZXhwIjoxNjUwMzUwOTY4LCJpYXQiOjE2NTAzNDczNjgsImlzcyI6InJlZHJlYW1lciIsInNjb3BlcyI6IiJ9.WWjCMbpWkpbzQulgqOQz5JqnC1lTEFG2_CTeFW21A8q7AKeEI_l2_ptqiG7lpcOCmojFW_3Zi3VAimO1k214cw"
}
```

* `token`: It will be expired after 1 hour.
* `refresh_token`: If token is expired, you can use this to refresh without signature.

#### 400, 500

```json
{
	"code": "ERROR_CODE"
}
```

#### Error Code

*

### Information

Posted: **Apr 20, 2022**


---

# 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-2022.redreamer.io/re-dreamer-labs-product/auth.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.
