Skip to main content
Version: 1.14

Retrieve token REST

Retrieve a token

Request

descriptionurlverb
Authentication endpoint (OAuth 2)<HOST>/api/v1/rs-authentication/oauth/tokenPOST

Request headers

{
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json",
"Authorization": "Basic Y2xpZW50OnNlY3JldA=="
}

Query parameters

ParameterTypeOptionalDescription
grant-typeStringNoThe authentication grant_type. REGARDS only allows password value
scopeStringNoThe REGARDS project (aka tenant) to authenticate to
usernameStringNoUser login
passwordStringNoUser password

Response

Hereunder is a response exemple. The access_token is the token you will need to access every REGARDS API endpoints.

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey...",
"email": "user@regards.fr",
"expires_in": 43199,
"role": "USER_ROLE",
"scope": "project1",
"sub": "user@regards.fr",
"tenant": "project1",
"token_type": "bearer"
}

cURL example

You can access authentication endpoint with a cURL request to the RS-AUTHENTICATION microservice

curl -X POST `${HOST}`/api/v1/rs-authentication/oauth/token?grant_type=password&scope=<project>&username=<login>&password=<password> \
-H 'Authorization: Basic Y2xpZW50OnNlY3JldA==' \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Accept: application/json'

Token usage

To use the generated token, adds the header Authorization to your request.

Request headers

{
"Authorization": "Bearer <token>",
[...]
}

For example, to import notifier rules:

curl -v -XPUT ${HOST}/api/v1/rs-notifier/rule \
-H 'Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey...' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json'
--data [...]