Format and .clang-format
This commit is contained in:
1 parent
6aed7b0027
commit
b94b634a87
47 files changed
+42341
-39711
No files matched your search
@@ -11,47 +11,57 @@
|
||||
|
||||
#include <Spotify/Client.hpp> // for ProxyConfig + CurlDeleter + ProxyType
|
||||
|
||||
namespace Spotify {
|
||||
namespace Spotify
|
||||
{
|
||||
|
||||
struct TokenSet {
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string scope;
|
||||
std::string refresh_token;
|
||||
std::int64_t expires_at_utc{}; // unix seconds
|
||||
struct TokenSet {
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string scope;
|
||||
std::string refresh_token;
|
||||
std::int64_t expires_at_utc{}; // unix seconds
|
||||
|
||||
bool IsExpired(std::chrono::seconds skew = std::chrono::seconds{60}) const;
|
||||
};
|
||||
bool IsExpired(std::chrono::seconds skew = std::chrono::seconds{
|
||||
60}) const;
|
||||
};
|
||||
|
||||
class PkceAuth {
|
||||
public:
|
||||
PkceAuth(std::string clientId, std::string redirectUri, std::filesystem::path tokenCachePath);
|
||||
class PkceAuth
|
||||
{
|
||||
public:
|
||||
|
||||
void SetProxy(ProxyConfig p) { m_Proxy = std::move(p); }
|
||||
void SetVerbose(bool v) { m_Verbose = v; }
|
||||
PkceAuth(std::string clientId,
|
||||
std::string redirectUri,
|
||||
std::filesystem::path tokenCachePath);
|
||||
|
||||
// One-time interactive step: prints URL and waits for redirect; stores refresh token.
|
||||
void AuthorizeAndStore(const std::vector<std::string>& scopes,
|
||||
std::chrono::milliseconds timeout = std::chrono::minutes(5));
|
||||
void SetProxy(ProxyConfig p) { m_Proxy = std::move(p); }
|
||||
void SetVerbose(bool v) { m_Verbose = v; }
|
||||
|
||||
// Headless: load from cache and refresh if needed.
|
||||
TokenSet LoadOrRefresh();
|
||||
// One-time interactive step: prints URL and waits for redirect;
|
||||
// stores refresh token.
|
||||
void AuthorizeAndStore(
|
||||
const std::vector<std::string>& scopes,
|
||||
std::chrono::milliseconds timeout = std::chrono::minutes(5));
|
||||
|
||||
private:
|
||||
std::string m_ClientId;
|
||||
std::string m_RedirectUri;
|
||||
std::filesystem::path m_TokenCachePath;
|
||||
ProxyConfig m_Proxy;
|
||||
bool m_Verbose = false;
|
||||
// Headless: load from cache and refresh if needed.
|
||||
TokenSet LoadOrRefresh();
|
||||
|
||||
TokenSet ExchangeCodeForToken(const std::string& code, const std::string& codeVerifier);
|
||||
TokenSet RefreshAccessToken(const TokenSet& current);
|
||||
private:
|
||||
|
||||
void Save(const TokenSet& t) const;
|
||||
std::optional<TokenSet> Load() const;
|
||||
std::string m_ClientId;
|
||||
std::string m_RedirectUri;
|
||||
std::filesystem::path m_TokenCachePath;
|
||||
ProxyConfig m_Proxy;
|
||||
bool m_Verbose = false;
|
||||
|
||||
static std::int64_t NowUnixSeconds();
|
||||
friend TokenSet;
|
||||
};
|
||||
TokenSet ExchangeCodeForToken(const std::string& code,
|
||||
const std::string& codeVerifier);
|
||||
TokenSet RefreshAccessToken(const TokenSet& current);
|
||||
|
||||
} // namespace ts6bot
|
||||
void Save(const TokenSet& t) const;
|
||||
std::optional<TokenSet> Load() const;
|
||||
|
||||
static std::int64_t NowUnixSeconds();
|
||||
friend TokenSet;
|
||||
};
|
||||
|
||||
} // namespace Spotify
|
||||
Reference in new issue
Block a user