> For the complete documentation index, see [llms.txt](https://docs.roboteasy.tech/orquestrador/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboteasy.tech/orquestrador/geral/integracoes-via-api/realizar-autenticacao.md).

# Realizar Autenticação

Lista de APIs disponíveis para autenticação nas aplicações, de modo a fazer execuções de robôs ou consumir resultado das execuções.

{% hint style="warning" %}
**IMPORTANTE**

A senha enviada na requisição deverá ser convertida para Base64.
{% endhint %}

## Autenticação

<mark style="color:green;">`POST`</mark> `https://app.rpaidea.com/api/user/auth`

Login no sistema utiliza a autenticação auth2 "Bearer authentication".

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | string | application/json |

#### Request Body

| Name                               | Type   | Description                                                                                                     |
| ---------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------- |
| <mark style="color:red;">\*</mark> | object | <p>{<br>    "username": "<user@agapys.com>",<br>    "password": "<strong>senha\_em\_base\_64</strong>"<br>}</p> |

{% tabs %}
{% tab title="200 Login efetuado com sucesso." %}

```javascript
Bearer {CÓDIGO BEARER}
```

{% endtab %}

{% tab title="401 Não autorizado." %}

```javascript
{
  "timestamp": 1574970103297,
  "status": 401,
  "error": "Unauthorized",
  "message": "Unauthorized",
  "path": "/api/user/auth"
}
```

{% endtab %}
{% endtabs %}

## Autenticação v2

<mark style="color:green;">`POST`</mark> `https://app.rpaidea.com/api/user/v2/auth`

Login no sistema utiliza o padrão OAuth 2.0.

#### Headers

| Name                               | Type   | Description      |
| ---------------------------------- | ------ | ---------------- |
| <mark style="color:red;">\*</mark> | string | application/json |

#### Request Body

| Name                               | Type   | Description                                                                                                      |
| ---------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------- |
| <mark style="color:red;">\*</mark> | object | <p>{<br>    "username": "<user@agapys.com>",<br>    "password": "<strong>senha\_em\_base\_64</strong>",<br>}</p> |

{% tabs %}
{% tab title="200 Login efetuado com sucesso" %}

```javascript
{
  "access_token": "{CÓDIGO BEARER}",
  "token_type": "bearer",
  "expires_in": 2592000
}
```

{% endtab %}

{% tab title="401 Não autorizado" %}

```javascript
{
  "timestamp": 1574970103297,
  "status": 401,
  "error": "Unauthorized",
  "message": "Unauthorized",
  "path": "/api/user/auth"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Perceba que no retorno de sucesso (200) da autenticação, a API retorno o código token Bearer. Este código deverá ser utilizado em quaisquer outras requisições no método Authorization.
{% endhint %}
