5#include <CesiumUtility/Result.h>
28 parse(
const std::string& tokenStr);
47 const std::string&
getToken()
const {
return _token; }
73 const std::string& token,
75 std::string&& userName,
76 std::vector<std::string>&& scopes,
77 int64_t notValidBefore,
92 const std::string& token,
93 std::string&& iTwinId,
95 : _token(token), _contents(
std::move(iTwinId)), _expires(expires) {}
101 struct AccessTokenContents {
105 std::string userName;
107 std::vector<std::string> scopes;
109 int64_t notValidBefore;
119 using AuthenticationTokenContents =
120 std::variant<AccessTokenContents, std::string>;
123 AuthenticationTokenContents _contents;
static CesiumUtility::Result< AuthenticationToken > parse(const std::string &tokenStr)
Creates a new AuthenticationToken by parsing the provided JWT authentication token.
AuthenticationToken(const std::string &token, std::string &&iTwinId, int64_t expires)
Creates a new AuthenticationToken for a share 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.
const std::string & getToken() const
Returns the contained token string.
std::string getTokenHeader() const
Returns the HTTP Authorization header for this token.
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.
Classes for interacting with the iTwin API.
Holds the result of an operation. If the operation succeeds, it will provide a value....