With auth enabled, you have to retrieve a JWT token before you can access the API calls.
Username/password login
Send the username and password, as defined in api.auth.username and api.auth.password, in the body of the request to the /api/login endpoint in order to obtain valid access and refresh JWT.
The expiry date is stored in the payload of the access token exp field, or the seconds until it expires is stored in the field exi.
In order to obtain a new access token, use the refresh_token for a call to /api/login/refresh:
After the refresh token expires, you have to login again with your username and password.
By creating a new core client, the login automatically happens. If the login fails, coreclient.New() will return an error.
Description:
Retrieve an access and a refresh token
post
Retrieve valid JWT access and refresh tokens to use for accessing the API. Login either by username/password or Auth0 token
Authorizations
AuthorizationstringRequired
Body
passwordstringRequired
usernamestringRequired
Responses
200
OK
application/json
access_tokenstringOptional
refresh_tokenstringOptional
400
Bad Request
application/json
403
Forbidden
application/json
500
Internal Server Error
application/json
post
/api/login
Auth0 login
Send a valid Auth0 access JWT in the Authorization header to the /api/login endpoint in order to obtain an access and refresh JWT. The Auth0 tenant and the allowed users must be defined in the configuration.
Example:
Retrieve an access and a refresh token
post
Retrieve valid JWT access and refresh tokens to use for accessing the API. Login either by username/password or Auth0 token
Authorizations
AuthorizationstringRequired
Body
passwordstringRequired
usernamestringRequired
Responses
200
OK
application/json
access_tokenstringOptional
refresh_tokenstringOptional
400
Bad Request
application/json
403
Forbidden
application/json
500
Internal Server Error
application/json
post
/api/login
JWT refresh
In order to obtain a new access token, use the refresh_token for a call to /api/login/refresh. Example:
On successful login, the response looks like this:
The client handles the refresh of the tokens automatically. However, the access_token can also be updated manually:
The client handles the refresh of the tokens automatically. However, you can extract the currently used tokens from the client:
You can use these tokens to continue this session later on, given that at least the refresh token didn't expire yet. This saves the client a login round-trip:
The username and password should be provided as well, in case the refresh token expires.
Once the refresh token expires, you have to login again with your username and password, or a valid Auth0 token.
Description:
Retrieve a new access token
get
Retrieve a new access token by providing the refresh token