Longbridge OpenAPI C++ SDK
Public Member Functions | List of all members
longbridge::OAuthBuilder Class Reference

#include <oauth.hpp>

Public Member Functions

 OAuthBuilder (const std::string &client_id, uint16_t callback_port=0)
 
void build (std::function< void(const std::string &)> open_url, AsyncCallback< void *, OAuth > callback)
 

Detailed Description

Builder for constructing an OAuth 2.0 client

Tries to load an existing token from ~/.longbridge-openapi/tokens/<client_id>. If the token is missing or expired, starts a local callback server and calls open_url so the caller can open the authorization URL in a browser.

Constructor & Destructor Documentation

◆ OAuthBuilder()

longbridge::OAuthBuilder::OAuthBuilder ( const std::string &  client_id,
uint16_t  callback_port = 0 
)
Parameters
client_idOAuth 2.0 client ID from the Longbridge developer portal
callback_portLocal callback server port; pass 0 to use the default (60355)

Member Function Documentation

◆ build()

void longbridge::OAuthBuilder::build ( std::function< void(const std::string &)>  open_url,
AsyncCallback< void *, OAuth callback 
)

Asynchronously build an OAuth 2.0 client

Parameters
open_urlCalled with the authorization URL during the auth flow
callbackInvoked on completion; result data is OAuth*

The documentation for this class was generated from the following file: