Authentication

šŸ“˜

We are using Bearer token to authenticate each request.

Bearer Token

Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name ā€œBearer authenticationā€ can be understood as ā€œgive access to the bearer of this token.ā€ 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:

Authorization: Bearer <token>

How to get the token ?

To get the token you have to make a POST request to the endpoint /authenticate with your credentials

curl --request POST \
     --url {baseUrl}/authenticate \
     --header 'accept: application/json' \
     --header 'content-type: application/json'
     --data '
      {
        "email": "[email protected]",
        "password": "password"
      }
      '

The response will provide you the token to access the API.

{
  "auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI"
}

How to use the token ?

This is an example to use the token in a request, we will request labels

GET "{baseUrl}/labels"

curl --request GET \
     --url 'https://virtserver.swaggerhub.com/floriandonod/12plus2/1.0.0/labels?page=1' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer fdksjflkjsdlkfds'