Implements the OAuth2 Authorization Code flow with optional PKCE.
More...
#include <OAuthPkceClient.hpp>
|
| using | TokenParser |
| | Callback type for custom token parsing when JSON support is disabled.
|
|
| | OAuthPkceClient (const OAuthConfig &config) |
| | Constructs a client with the given OAuth configuration.
|
| void | set_token_parser (TokenParser parser) |
| | Sets a custom token parser for non-JSON builds.
|
| std::string | build_authorization_url () |
| | Builds the full authorization URL with query parameters.
|
| bool | exchange_code (const std::string &code, AuthResult &out_result) |
| | Exchanges an authorization code for an access token.
|
| bool | refresh_access_token (const std::string &refresh_token, AuthResult &out_result) |
| | Refreshes an access token using a refresh token.
|
| bool | validate_state (const std::string &returned_state) const |
| | Validates the state parameter returned by the authorization server.
|
| const std::string & | code_verifier () const |
| | Returns the code verifier used in the last PKCE exchange.
|
| const std::string & | state () const |
| | Returns the state parameter used in the last authorization request.
|
Implements the OAuth2 Authorization Code flow with optional PKCE.
Uses the standalone free functions kurlyk::http_post and kurlyk::http_request so it does not depend on any particular HttpClient instance.
Definition at line 31 of file OAuthPkceClient.hpp.
◆ TokenParser
Initial value:std::function<bool(
const std::string& raw_response,
std::string& out_error)>
Holds the result of an OAuth2 token exchange.
Callback type for custom token parsing when JSON support is disabled.
Definition at line 34 of file OAuthPkceClient.hpp.
◆ OAuthPkceClient()
| kurlyk::http::auth::OAuthPkceClient::OAuthPkceClient |
( |
const OAuthConfig & | config | ) |
|
|
inlineexplicit |
Constructs a client with the given OAuth configuration.
- Parameters
-
| config | OAuth client configuration. |
Definition at line 41 of file OAuthPkceClient.hpp.
◆ build_authorization_url()
| std::string kurlyk::http::auth::OAuthPkceClient::build_authorization_url |
( |
| ) |
|
|
inline |
Builds the full authorization URL with query parameters.
- Returns
- The authorization URL ready to open in a browser.
Definition at line 52 of file OAuthPkceClient.hpp.
◆ code_verifier()
| const std::string & kurlyk::http::auth::OAuthPkceClient::code_verifier |
( |
| ) |
const |
|
inline |
◆ exchange_code()
| bool kurlyk::http::auth::OAuthPkceClient::exchange_code |
( |
const std::string & | code, |
|
|
AuthResult & | out_result ) |
|
inline |
Exchanges an authorization code for an access token.
- Parameters
-
| code | The authorization code received from the OAuth server. |
| out_result | Receives the authentication result. |
- Returns
- true on success; inspect out_result on failure.
Definition at line 97 of file OAuthPkceClient.hpp.
◆ parse_token_response()
| bool kurlyk::http::auth::OAuthPkceClient::parse_token_response |
( |
const std::string & | raw_response, |
|
|
AuthResult & | out_result ) |
|
inlineprotected |
◆ refresh_access_token()
| bool kurlyk::http::auth::OAuthPkceClient::refresh_access_token |
( |
const std::string & | refresh_token, |
|
|
AuthResult & | out_result ) |
|
inline |
Refreshes an access token using a refresh token.
- Parameters
-
| refresh_token | The refresh token. |
| out_result | Receives the authentication result. |
- Returns
- true on success; inspect out_result on failure.
Definition at line 162 of file OAuthPkceClient.hpp.
◆ set_token_parser()
| void kurlyk::http::auth::OAuthPkceClient::set_token_parser |
( |
TokenParser | parser | ) |
|
|
inline |
Sets a custom token parser for non-JSON builds.
- Parameters
-
| parser | Callback invoked when JSON support is unavailable. |
Definition at line 46 of file OAuthPkceClient.hpp.
◆ state()
| const std::string & kurlyk::http::auth::OAuthPkceClient::state |
( |
| ) |
const |
|
inline |
Returns the state parameter used in the last authorization request.
Definition at line 232 of file OAuthPkceClient.hpp.
◆ validate_state()
| bool kurlyk::http::auth::OAuthPkceClient::validate_state |
( |
const std::string & | returned_state | ) |
const |
|
inline |
Validates the state parameter returned by the authorization server.
- Parameters
-
| returned_state | The state parameter from the redirect. |
- Returns
- true if the state matches the internally stored value.
Definition at line 222 of file OAuthPkceClient.hpp.
◆ m_code_challenge
| std::string kurlyk::http::auth::OAuthPkceClient::m_code_challenge |
|
private |
◆ m_code_verifier
| std::string kurlyk::http::auth::OAuthPkceClient::m_code_verifier |
|
private |
◆ m_config
| OAuthConfig kurlyk::http::auth::OAuthPkceClient::m_config |
|
private |
◆ m_state
| std::string kurlyk::http::auth::OAuthPkceClient::m_state |
|
private |
◆ m_token_parser
| TokenParser kurlyk::http::auth::OAuthPkceClient::m_token_parser |
|
private |
The documentation for this class was generated from the following file: