---
updatedAt: 2025-03-07T10:54:06.000Z
agentTools:
  projectIndex: https://getquanty.readme.io/llms.txt
---

# Bearer Authentication

# 🔹 Introduction

**Bearer authentication** is an [HTTP authentication scheme](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) that involves security tokens called bearer tokens. The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the `Authorization` header when making requests to protected resources :

```html html
Authorization: Bearer '<accessToken>'
```

The GetQuanty API base url is `https://api.getquanty.com/v1`.

# 🔹Generate your Bearer Token

In order to generate a bearer token you first need to get an API key, then you can request your token by using the `/oauth/token` route.

### Get an API key

You can get your API key from your [Account Settings](https://next.getquanty.com/#/config/api) in the GetQuanty platform. The key provided is a couple of `<clientId>`and `<clientSecret>`strings.

> 🚧
>
> For security reasons, do not share your API key with anyone else.

### Get your access token

Encode your `<clientId>` and `<clientSecret>` to Base64  :

```powershell bash
echo -n '<clientId>:<clientSecret>' | base64
```

> 🚧
>
> Replace `<clientId>`and `<clientSecret>` with yours and don't forget `:` between them

Copy the encoded value and use it in the `Authorization` header as a `Basic` value :

| Header        | Value                             |
| :------------ | :-------------------------------- |
| Authorization | Basic `<encoded-api-key>`         |
| Content-Type  | application/x-www-form-urlencoded |

```curl
curl https://api.getquanty.com/v1/oauth/token \
    -d "grant_type=password" \
    -d "username=<username>" \
    -d "password=<password>" \
    -H "Authorization: Basic <encoded-api-key>" \
    -H "Content-Type: application/x-www-form-urlencoded"
```

> 🚧
>
> Replace `<username>`and `<password>` with your GetQuanty account credentials.
>
> Replace `<encoded-api-key>` with your encoded api key.
>
> Don't forget the `grant_type=password` along with your credentials.

You should now have a response from the server with your `accessToken` and `refreshToken` .

> 📘
>
> In the response you can see `accessTokenExpiresAt` and `refreshTokenExpiresAt`. You will need to handle expiration of your tokens.

# 🔹Refresh your Bearer Token

When you request an access token you also get a refresh token. This token can be used to generate a new access token for exemple if the old one expires. Keep in mind that you must refresh your access token if it expires in order to continue using the API.

```curl
curl https://api.getquanty.com/v1/oauth/token \
    -d "grant_type=refresh_token" \
    -d "refresh_token=<refreshToken>" \
    -H "Authorization: Basic <encoded-api-key>" \
    -H "Content-Type: application/x-www-form-urlencoded"
```

> 🚧
>
> Replace `<refreshToken>` with the refresh token you got earlier.
>
> Replace `<encoded-api-key>` with your encoded api key.
>
> Don't forget the `grant_type=refresh_token` along with your refresh token

# 🔹Use your Bearer Token

Now that you got your access token, you can use it to interact with the GetQuanty API endpoints by setting it in the `Authorization` header as a `Bearer` value :

| Header        | Value                  |
| :------------ | :--------------------- |
| Authorization | Bearer `<accessToken>` |
| Content-Type  | application/json       |

```curl
curl -X POST https://api.getquanty.com/v1/companies/identified \
    -H "Authorization: Bearer <accessToken>" \
    -H "Content-Type: application/json" \
    -d '{ "from": 1,"dateMin": "2023-01-01","dateMax": "2023-01-07"}'
```

> 🚧
>
> Replace `<accessToken>` with the access token you got earlier.
>
> Don't forget the `Content-Type: application/json` in your headers since the communication with the API is using JSON.

> 👍 Secure Communication
>
> All API requests must be made over **HTTPS**.