# Obtaining Authorization Tokens

Source: https://docs.annoto.net/developers/rest-api/authentication-obtaining-authorization-tokens

Host Authorization Token

`POST` `/hosts/auth`

Obtain the authentication header

**Headers**

| Name | Value |
|---|---|
| Content-Type | `application/json` |
| Origin | `SITE_URL` |

- SITE\_URL - The Authorized Site URL

This is the only request that does not require the Host Authorization Header for obvious reasons :smile:



**Body**

| Name | Type | Description |
|---|---|---|
| `client_id` | string | CLIENT\_ID provided by Annoto for SITE\_URL |
| `origin` | string | The Authorized SITE\_URL |
| `session_id` | string | random string for identifying the visitor SESSION\_ID |
| `visitor_id` | string | random string for identifying the site VISITOR\_ID |

```json
{
  "client_id": "CLIENT_ID"
  "origin": "SITE_URL"
  "session_id": "SESSION_ID",
  "visitor_id": "VISITOR_ID"
}

```

**Response**

200

```json
{
    "host_token": "HOST_JWT_AUTHORIZATION_TOKEN",
    "settings": {
        "enableSSO": true,
        "publicName": "OPTIONAL_PUBLIC_NAME_OF_THE_SITE",
    },
    "name": "NAME_OF_THE_SITE"
}

```



400

```json
{
  "message": "Bad request",
  "statusCode": 400
}

```



401

```json
{
  "message": "Unauthorized",
  "statusCode": 401
}

```



- HOST\_JWT\_AUTHORIZATION\_TOKEN - The JWT token to be used in Host Authorization Header

User Authorization Token via SSO

`POST` `/auth/sso`

Annoto supports various authentication strategies for users, eventually all the strategies yield the user authorization JWT token to be used by the APIs, this API is for SSO strategy.

**Headers**

| Name | Value |
|---|---|
| Content-Type | `application/json` |
| Host-Authorization | `Bearer <token>` |

- `<token>` - The HOST\_JWT\_AUTHORIZATION\_TOKEN

**Body**

| Name | Type | Description |
|---|---|---|
| `token` | string | the generated user SSO Token according to   [SSO (Single Sign On)](https://docs.annoto.net/developers/integrations/sso-single-sign-on#setup) |

```json
{
  "token": "USER_SSO_JWT_TOKEN"
}

```

Hints for generating the USER\_SSO\_JWT\_TOKEN

- For `scope` use appropriate scope based on the permission requirements of the APIs to be used. For most APIs `super-mod` scope would be sufficient.
- For `name` we suggest using a naming convention such as: `[System] Super Moderator`



**Response**

200

```json
{
  "access_token": "USER_JWT_AUTHORIZATION_TOKEN",
  "scope": ["user"],
  "sso_id": "10024010",
  "permissions": {
    "hostScopes": [
      "super-mod",
      "moderator",
      "member",
      "user"
    ],
    "scopes": [
      "super-mod",
      "moderator",
      "member",
      "user"
    ]
  }
}

```



400

```json
{
  "message": "Bad request",
  "statusCode": 400
}

```



401

```json
{
  "message": "Unauthorized",
  "statusCode": 401
}

```



- USER\_JWT\_AUTHORIZATION\_TOKEN - The User Authentication JWT token

USER\_JWT\_AUTHORIZATION\_TOKEN is coupled to the host, and cannot be used for other hosts
