...
Most of API methods require authorization. Server expects to receive Authorization
header value inside HTTP request. As header value client should provide access token acquired before that moment by any of login methods.
Access token is relatively short lived, while refresh token's lifespan can be in scope of months. Refresh token is used for acquiring new access token when old one expires. Logging in with refresh token doesn't require entering user name and password once again, so it's a preferable login method for mobile applications.
First login
There are several ways to login, most common one is Login
method, accessible by path api/security/authentication/login
. It accepts 3 parameters:
...
Server returns access and refresh tokens. Both tokens have expiration time and should not be used after that.Access token intended to be saved and used within subsequent calls to server. It is not recommended to login before each call to server.
Warning |
---|
DO NOT Common antipattern is to make a login call before each call to server. This results in a lot of refresh tokens being active for prolonged period of time which is potential security hazard. Moreover, login operation is time consuming by design, so by logging in before every call you decrease the performance of your system. |
Tip |
---|
DO Save both access and refresh tokens and provide access token value in Authorization header. When it expires, use |
...
|
Refresh token
To continue being be able to call server after access token expiration client should call LoginWithRefreshToken
method accessible by path api/security/authentication/loginWithRefreshToken
. Method does not require authorization header, therefore it can be used after access token expiration time (but before refresh token expiration). It accepts following parameters:
...