Authentication
Authenticate to the Polarity v5 REST API
Overview
Authentication against the Polarity REST API requires acquiring a Bearer token. The token can then be used in subsequent requests to the API where authentication is required.
Authenticating
To begin, you will need to authenticate to the Polarity Server to obtain a reusable bearer token that will be used with subsequent authenticated requests.
To authenticate to the Polarity REST API you must send a POST
request that includes an identification
and password
property in your JSON data payload to the /api/users/login
endpoint:
Examples
Return Payload
The request will return a JSON payload with a token in addition to the user’s settings:
The token is tied to the identity of the requesting user and includes an expiration_time
which is specified as a Unix Epoch Timestamp in seconds. You will then use the token in subsequent requests by including it in the Authorization
header as a Bearer
token:
HTTP Status Codes
200
Successful login
401
Invalid username or password
400
Malformed request payload
Refreshing a Token
You can refresh a token using the GET /api/users/refresh
endpoint. By passing in the existing Token as part of the Authorization
header, this endpoint will return a new token with a refreshed expiration. The format of the return payload is the same as the /api/users/login
endpoint.
Examples
Invalidating a Token
Once you are done working with the REST API, you can invalidate the token by making a call to POST /api/users/logout
using the token you wish to invalidate.
Examples
The endpoint will return a 200
HTTP Status Code is you are successfully logged out (i.e., the provided token is invalidated)
Last updated