> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.bienport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authentication guarantees privacy of API Services by authenticating users. Authentication requires users to log in before accessing Bienport API Services. This guide covers setup for each available handshake method.

<Danger>
  All authorized endpoints require `Authorization: Bearer <ACCESS_TOKEN>` header in request!<br /> Otherwise API client will receive an error message with status `401 - Unauthorized`
</Danger>

Example Header:

```ini theme={null}
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJ1c2VyaWRcIjoyMDY0MSxcInNjcmVlbk5hbWVcIjpcImJpZW5wb3J0LmZsZXh5d2F0dFwiLFwicmVtZW1iZXJNZVwiOnRydWV9IiwiaWF0IjoxNzU2MTQwODE3LCJleHAiOjE3NjM5MTY4MTd9.Vg9gAG1dn8v8c8f0J6H08NW2Bomwsyqk8LfDnc7WZFlX2zZrhZMoC-ru3oZL0wg0TuYaqTJ2cr9Hky4ddsGR9A
```

# 1. Login Operation

> Login Operations are Made With ScreenName And Password<br />
> API Endpoint: `/auth/login`

Example Request Payload:

```json theme={null}
{
  "screenName": "905554447788",
  "password": "password",
  "rememberMe": true
}
```

Example Success Response:

```json theme={null}
{
    "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJ1c2VyaWRcIjoyMDY0MSxcInNjcmVlbk5hbWVcIjpcImJpZW5wb3J0LmZsZXh5d2F0dFwiLFwicmVtZW1iZXJNZVwiOnRydWV9IiwiaWF0IjoxNzU2MTQwODE3LCJleHAiOjE3NjM5MTY4MTd9.Vg9gAG1dn8v8c8f0J6H08NW2Bomwsyqk8LfDnc7WZFlX2zZrhZMoC-ru3oZL0wg0TuYaqTJ2cr9Hky4ddsGR9A",
    "mqUser": "mqttuser",
    "mqPassword": "XFAYdhtDquax/rtofHjqCw==",
    "userId": 20641,
    "emailAddress": "demo@bienport.com",
    "screenName": "bienport.demo",
    "localeId": "tr_TR",
    "roles": [
        {
            "roleId": 20166,
            "roleName": "User",
            "type": 1,
            "inherited": false,
            "typePK": 1
        }
    ],
    "organizations": [
        {
            "name": "Bimetri",
            "id": 20635
        }
    ],
    "organizationIds": [
        20635
    ],
    "resources": [
        {
            "resourceId": 17305,
            "networkId": "26:AA:E0:23:23:5E",
            "resourceName": "Bimetri Demo Konsantratör",
            "enabled": false,
            "treePath": "/17305/",
            "orgId": 20635,
            "resourceType": "Gateway",
            "deviceSubType": "gateway"
        },
        {
            "resourceId": 17354,
            "networkId": "26:AA:09:0B:6D:FB",
            "resourceName": "Bimetri Demo Pano",
            "enabled": true,
            "treePath": "/17354/",
            "orgId": 20635,
            "resourceType": "Gateway",
            "deviceSubType": "gateway"
        }
    ]
}
```

<Tip>
  Access Tokens are valid for only 3 hour when "Remember Me" is selected as 'false'.
  Ther are valid for 3 months when "Remember Me" is selected as 'true'.
</Tip>

Possible Error Responses:

```json theme={null}
{
    "statusCode": 401,
    "error": "AuthorizationException",
    "message": "Incorrect username or password. Username: bienport.demo",
    "path": "/auth/login"
}
```
