Skip to main content
Version: 2.1.0

Get JWT Token

Introduction​

This section describes how to authenticate through rs-authentication microservice and retrieve a JWT Token. JWT token is mandatory to access every REGARDS microservice REST API.

REST API​

How to​

The Regards REST API concept describes how REST interfaces must be handled to submit requests.

Endpoint​

EndpointVerb
/oauth/tokenPOST

Request headers​

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

Query parameters​

The only query parameter needed is the scope parameter containing the project or tenant to authenticate to.

ParameterTypeOptionalDescription
scopeStringNoThe REGARDS project or tenant to authenticate to

Body parameters​

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

Response​

Below 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"
}
ParameterTypeDescription
access_tokenStringThe JWT token to use in rest api
emailStringemail of the authenticated user
expires_inNumberThe generated token will expires in this number os seconds
roleStringRole of the authenticated user
scopeStringproject or tenant
subStringLogin of the authenticated user
tenantStringproject or tenant
token_typeStringAlways bearer

Example with cURL​

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

curl '<host>/api/v1/rs-authentication/oauth/token?scope=<scope>' \
--header 'Authorization: Basic Y2xpZW50OnNlY3JldA==' \
--header 'Content-Type: application/json' \
-d '{"username": "my_username","password": "my_password","grant_type": "password"}'

Token usage​

To lean how to use retrieved token to access all REGARDS microservices rest endpoints see REST API Guide section.