diff options
| author | Aotrix <[email protected]> | 2026-01-25 02:54:06 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-01-25 02:54:06 +0100 |
| commit | 9465c64a517181b650c3b476752536ed9c49befb (patch) | |
| tree | 5e2f1cd80ce4663cfce0b5ed865f86dfaf9bfe3b /battleNetApi/include | |
| parent | 15de61ad9fead748287537cdcc11fc82683a09ef (diff) | |
fixed token generation when content length is inferior to min
Diffstat (limited to 'battleNetApi/include')
| -rw-r--r-- | battleNetApi/include/token.hpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/battleNetApi/include/token.hpp b/battleNetApi/include/token.hpp index 34c6d3e..1941ce5 100644 --- a/battleNetApi/include/token.hpp +++ b/battleNetApi/include/token.hpp @@ -5,6 +5,8 @@ class Token { public: Token(const std::string &iTokenFilePath); std::string text() const; + const bool hasTokenExpired() const; + void updateToken(); private: const std::string mFilePath; //!< Path to the token file @@ -13,16 +15,17 @@ class Token { std::string mToken; //!< Token value /** - * @return A token that a user can use to perform API requests. - * A new token might be computed if the current token lifetime expired. + * @return An access token that a user can use to perform API requests. + * First, the cache file is checked. + * A new token is computed if the current token lifetime expired, + * or if there is no token at all. */ std::string generateToken(); - const bool hasTokenExpired() const; - void writeNewTokenToLocalFile(const std::string &iTokenContent) const; + void writeNewTokenToLocalFile(const std::pair<std::string, std::uint64_t> &iToken) const; std::string getTokenFromLocalFile() const; - std::string getTokenWithApi() const; + std::pair<std::string, std::uint64_t> getTokenWithApi() const; std::chrono::seconds getCurrentTime() const; static size_t curlCallbackStringOutput(void *iPtr, size_t iSize, size_t iNmemb, std::string *iUserData); - friend class TokenTests; + static const std::uint16_t kTokenContentMinLength{10}; }; |
