cesium-native 0.46.0
Loading...
Searching...
No Matches
AuthenticationToken.h
1#pragma once
2
3#include "Library.h"
4
5#include <CesiumUtility/Result.h>
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
15class CESIUMITWINCLIENT_API AuthenticationToken {
16public:
26 parse(const std::string& tokenStr);
27
34 bool isValid() const;
35
40 int64_t getExpirationTime() const { return _expires; }
41
45 const std::string& getToken() const { return _token; }
46
63 const std::string& token,
64 std::string&& name,
65 std::string&& userName,
66 std::vector<std::string>&& scopes,
67 int64_t notValidBefore,
68 int64_t expires)
69 : _token(token),
70 _name(std::move(name)),
71 _userName(std::move(userName)),
72 _scopes(std::move(scopes)),
73 _notValidBefore(notValidBefore),
74 _expires(expires) {}
75
76private:
77 std::string _token;
78 std::string _name;
79 std::string _userName;
80 std::vector<std::string> _scopes;
81 int64_t _notValidBefore;
82 int64_t _expires;
83};
84} // namespace CesiumITwinClient
An authentication token obtained from the iTwin OAuth2 flow.
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 &&name, std::string &&userName, std::vector< std::string > &&scopes, int64_t notValidBefore, int64_t expires)
Creates a new AuthenticationToken.
const std::string & getToken() const
Returns the contained token string.
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.
STL namespace.
Holds the result of an operation. If the operation succeeds, it will provide a value....
Definition Result.h:16