![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/AccessToken.h>
Represents an access token for a HTTP server. More...
Represents an access token for a HTTP server.
Also holds all informations to refresh the token.
Static Public Member Functions | |
static AccessToken | fromUsernameAndPassword (const std::string &username, const std::string &password) |
Generates an AccessToken from a username and password according to HTTP Basic Auth. | |
static Utils::Expected< AccessToken, std::string > | fromOAuth2 (const std::string &json, const Filesystem::Url &tokenEndpoint, const std::string &clientId) |
Parses an AccessToken from an OAuth2 JSON response. | |
Public Attributes | |
std::string | accessToken |
The actual access token for the API. | |
std::string | refreshToken |
A token that can be used to obtain a new access token. | |
std::string | scheme |
Auth scheme of the token, e.g. "Basic" or "Bearer". | |
std::chrono::time_point< std::chrono::system_clock > | expiresAfter |
Timepoint after which the accessToken is no longer valid. | |
std::chrono::time_point< std::chrono::system_clock > | refreshExpiresAfter |
Same as expiresAfter but for the refreshToken. | |
std::string | username |
without a refresh token, the username and password can be used to get a new token. | |
std::string | password |
std::string | tokenEndpoint |
The url from where the token was requested. | |
std::string | clientId |
The oauth client_id that was used to get the token. | |
|
static |
Generates an AccessToken from a username and password according to HTTP Basic Auth.
This will only fill the accessToken, username and password fields. All other fields will remain empty.
|
static |
Parses an AccessToken from an OAuth2 JSON response.
Fills all fields that are present in the JSON, except username and password.
std::string refreshToken |
A token that can be used to obtain a new access token.
Might be empty if no refresh token is available.
std::chrono::time_point<std::chrono::system_clock> expiresAfter |
Timepoint after which the accessToken is no longer valid.
Note that this is not entirely accurate and the token might actually expire a few seconds earlier.
std::string username |
without a refresh token, the username and password can be used to get a new token.
Will be empty if the user didn't login with username and password.
std::string tokenEndpoint |
The url from where the token was requested.
Can also be used to request a refresh token.