blob: f529a08600f979b5bf9894902bb2dce76538340b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <chrono>
#include <string>
class Token {
public:
Token(const std::string &iTokenFilePath, const std::string &iUsername, const std::string &iPassword);
std::string toString() const;
private:
const std::string mFilePath; //!< Path to the token file
const std::string mUsername; //!< Username for Battle.net API
const std::string mPassword; //!< Password for Battle.net API
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.
*/
std::string getValidToken();
const bool hasTokenExpired() const;
std::string writeNewTokenToLocalFile() const;
std::string getTokenFromLocalFile() const;
std::string getTokenWithApi() const;
std::chrono::seconds getCurrentTime() const;
std::string extractTokenWithRegex(const std::string &iText, const std::string &iRegex) const;
static size_t curlCallbackStringOutput(void *iPtr, size_t iSize, size_t iNmemb, std::string *iUserData);
friend class TokenTests;
};
|