![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
An OAuth access token and its expiry, the base of each broker's token-response class. More...
#include <algotradelib/src/network/oauth.hpp>
Public Member Functions | |
| void | from_json (const json::object &document) |
| Reads a token response. | |
| bool | valid (std::chrono::seconds margin=std::chrono::minutes(5)) const noexcept |
| Tests whether the token is set and stays valid for at least a margin. | |
Public Attributes | |
| std::string | access_token_ |
| The bearer token; do not log it. | |
| std::chrono::system_clock::time_point | expires_at_ {} |
| When the token expires. | |
An OAuth access token and its expiry, the base of each broker's token-response class.
The broker class derives from it (CRTP) and provides the static token_field() naming the token's JSON field, and from_json_impl(document) to read anything else (such as an absolute expiry).
| BrokerType | The derived broker token class. |
|
inline |
Reads a token response.
Reads the token, a relative expires_in (a whole number, or a string of one) if present, then calls the broker's from_json_impl, which may set an absolute expiry.
| document | The response. |
| std::runtime_error | if the token field is missing or not a string, or the response states no expiry (no lifetime is assumed); or whatever the broker's from_json_impl throws. |
|
inlinenoexcept |
Tests whether the token is set and stays valid for at least a margin.
| margin | How long it must still be valid. |
Definition at line 182 of file oauth.hpp.
Referenced by algotradelib::kis::KisRest::valid().
| std::string algotradelib::network::AuthBody< BrokerType >::access_token_ |
The bearer token; do not log it.
Definition at line 133 of file oauth.hpp.
Referenced by from_json(), and valid().
| std::chrono::system_clock::time_point algotradelib::network::AuthBody< BrokerType >::expires_at_ {} |
When the token expires.
Definition at line 135 of file oauth.hpp.
Referenced by from_json(), and valid().