![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
OAuth client credentials (an app key and secret), the base of each broker's credentials class. More...
#include <algotradelib/src/network/oauth.hpp>
Public Member Functions | |
| void | from_env () |
| Loads the credentials from the broker's environment variables. | |
| void | from_json (const std::string &filename) |
| Loads the credentials from a JSON file, in the broker's format. | |
| const std::string & | key () const noexcept |
| Returns the app key (client id). | |
| const std::string & | secret () const noexcept |
| Returns the app secret. | |
| std::string | to_jsonbody () const |
| Builds a JSON token-request body (grant type, key and secret under the broker's field names). | |
| std::string | to_form_urlencoded_body () const |
| Builds a form-encoded token-request body (grant_type, client_id, client_secret). | |
Static Public Attributes | |
| static constexpr std::string_view | grant_type = "client_credentials" |
| The OAuth grant type sent in a token request. | |
Protected Attributes | |
| std::string | key_ |
| The app key (client id). | |
| std::string | secret_ |
| The app secret. | |
OAuth client credentials (an app key and secret), the base of each broker's credentials class.
The broker class derives from it (CRTP) and provides from_env_impl(), from_json_impl(filename), and the static key_field() and secret_field() naming the token request's JSON fields.
| BrokerType | The derived broker credentials class. |
|
inline |
Loads the credentials from the broker's environment variables.
| std::runtime_error | (from the broker's implementation) if a variable is missing or invalid (such as a demo setting that is neither 0 nor 1). |
Definition at line 46 of file oauth.hpp.
Referenced by kis_credentials::load(), and kiwoom_credentials::load().
|
inline |
Loads the credentials from a JSON file, in the broker's format.
| filename | The file. |
| std::runtime_error | (from the broker's implementation) if the file cannot be read or is not valid JSON, or a field is missing, of the wrong type or invalid. |
Definition at line 54 of file oauth.hpp.
Referenced by kiwoom_credentials::load(), and kis_credentials::load_config().
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Builds a form-encoded token-request body (grant_type, client_id, client_secret).
|
inline |
|
staticconstexpr |
The OAuth grant type sent in a token request.
Definition at line 39 of file oauth.hpp.
Referenced by to_jsonbody().
|
protected |
The app key (client id).
Definition at line 94 of file oauth.hpp.
Referenced by key(), to_form_urlencoded_body(), and to_jsonbody().
|
protected |
The app secret.
Definition at line 96 of file oauth.hpp.
Referenced by secret(), to_form_urlencoded_body(), and to_jsonbody().