cesium-native 0.50.0
|
An authentication token obtained from the iTwin OAuth2 flow. More...
#include <CesiumITwinClient/AuthenticationToken.h>
Public Member Functions | |
bool | isValid () const |
Is this token currently valid? | |
int64_t | getExpirationTime () const |
Returns the number of seconds since the Unix epoch representing the time that this token expires. | |
const std::string & | getToken () const |
Returns the contained token string. | |
std::string | getTokenHeader () const |
Returns the HTTP Authorization header for this token. | |
AuthenticationToken (const std::string &token, std::string &&name, std::string &&userName, std::vector< std::string > &&scopes, int64_t notValidBefore, int64_t expires) | |
Creates a new AuthenticationToken for an access token. | |
AuthenticationToken (const std::string &token, std::string &&iTwinId, int64_t expires) | |
Creates a new AuthenticationToken for a share token. | |
Static Public Member Functions | |
static CesiumUtility::Result< AuthenticationToken > | parse (const std::string &tokenStr) |
Creates a new AuthenticationToken by parsing the provided JWT authentication token. | |
An authentication token obtained from the iTwin OAuth2 flow.
Definition at line 17 of file AuthenticationToken.h.
CesiumITwinClient::AuthenticationToken::AuthenticationToken | ( | const std::string & | token, |
std::string && | name, | ||
std::string && | userName, | ||
std::vector< std::string > && | scopes, | ||
int64_t | notValidBefore, | ||
int64_t | expires ) |
Creates a new AuthenticationToken
for an access token.
This constructor assumes all the data in the provided token has already been parsed. If not, you should call parse instead.
token | The full token string. |
name | The name of the token. |
userName | The name of the user this token belongs to. |
scopes | The set of scopes this token is valid for. |
notValidBefore | A UNIX timestamp representing the point in time that this token starts to be valid. |
expires | A UNIX timestamp representing the point in time that this token stops being valid. |
|
inline |
Creates a new AuthenticationToken
for a share token.
This constructor assumes all the data in the provided token has already been parsed. If not, you should call parse instead.
token | The full token string. |
iTwinId | The ID of the iTwin this share token provides access to. |
expires | A UNIX timestamp representing the point in time that this token stops being valid. |
Definition at line 91 of file AuthenticationToken.h.
|
inline |
Returns the number of seconds since the Unix epoch representing the time that this token expires.
Definition at line 42 of file AuthenticationToken.h.
|
inline |
Returns the contained token string.
Definition at line 47 of file AuthenticationToken.h.
std::string CesiumITwinClient::AuthenticationToken::getTokenHeader | ( | ) | const |
Returns the HTTP Authorization header for this token.
Access tokens use a Bearer
header while share tokens use a Basic
header.
bool CesiumITwinClient::AuthenticationToken::isValid | ( | ) | const |
Is this token currently valid?
For the token to be valid, it must currently be after its "not valid before" date but before its expiration date.
|
static |
Creates a new AuthenticationToken by parsing the provided JWT authentication token.
tokenStr | The JWT authentication token. |
Result
containing either the parsed AuthenticationToken or error messages.