Kurlyk
Toggle main menu visibility
Loading...
Searching...
No Matches
OAuthConfig.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef _KURLYK_HTTP_AUTH_DATA_OAUTH_CONFIG_HPP_INCLUDED
3
#define _KURLYK_HTTP_AUTH_DATA_OAUTH_CONFIG_HPP_INCLUDED
4
7
8
#include <string>
9
10
#if KURLYK_JSON_SUPPORT
11
# include <nlohmann/json.hpp>
12
#endif
13
14
namespace
kurlyk
{
15
18
struct
OAuthConfig
{
19
std::string
client_id
;
20
std::string
client_secret
;
21
std::string
authorization_endpoint
;
22
std::string
token_endpoint
;
23
std::string
redirect_uri
;
24
std::string
scope
;
25
bool
use_pkce
=
true
;
26
std::string
audience
;
27
std::string
prompt
;
28
std::string
access_type
;
29
};
30
31
}
// namespace kurlyk
32
33
#if KURLYK_JSON_SUPPORT
34
35
namespace
kurlyk
{
36
37
inline
void
to_json(nlohmann::json& j,
const
OAuthConfig& c) {
38
j = nlohmann::json{
39
{
"client_id"
, c.client_id},
40
{
"client_secret"
, c.client_secret},
41
{
"authorization_endpoint"
, c.authorization_endpoint},
42
{
"token_endpoint"
, c.token_endpoint},
43
{
"redirect_uri"
, c.redirect_uri},
44
{
"scope"
, c.scope},
45
{
"use_pkce"
, c.use_pkce},
46
{
"audience"
, c.audience},
47
{
"prompt"
, c.prompt},
48
{
"access_type"
, c.access_type}
49
};
50
}
51
52
inline
void
from_json
(
const
nlohmann::json& j,
OAuthConfig
& c) {
53
if
(j.contains(
"client_id"
)) c.client_id = j[
"client_id"
].get<std::string>();
54
if
(j.contains(
"client_secret"
)) c.client_secret = j[
"client_secret"
].get<std::string>();
55
if
(j.contains(
"authorization_endpoint"
)) c.authorization_endpoint = j[
"authorization_endpoint"
].get<std::string>();
56
if
(j.contains(
"token_endpoint"
)) c.token_endpoint = j[
"token_endpoint"
].get<std::string>();
57
if
(j.contains(
"redirect_uri"
)) c.redirect_uri = j[
"redirect_uri"
].get<std::string>();
58
if
(j.contains(
"scope"
)) c.scope = j[
"scope"
].get<std::string>();
59
if
(j.contains(
"use_pkce"
)) c.use_pkce = j[
"use_pkce"
].get<
bool
>();
60
if
(j.contains(
"audience"
)) c.audience = j[
"audience"
].get<std::string>();
61
if
(j.contains(
"prompt"
)) c.prompt = j[
"prompt"
].get<std::string>();
62
if
(j.contains(
"access_type"
)) c.access_type = j[
"access_type"
].get<std::string>();
63
}
64
65
}
// namespace kurlyk
66
67
#endif
// KURLYK_JSON_SUPPORT
68
69
#endif
// _KURLYK_HTTP_AUTH_DATA_OAUTH_CONFIG_HPP_INCLUDED
cryptox::from_json
void from_json(const nlohmann::json &j, ProxyConfig &config)
Deserializes ProxyConfig from JSON.
Definition
ProxyConfig.hpp:116
kurlyk
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
kurlyk::OAuthConfig
Stores client configuration for an OAuth2 Authorization Code + PKCE flow.
Definition
OAuthConfig.hpp:18
kurlyk::OAuthConfig::prompt
std::string prompt
Optional prompt parameter (e.g. "consent").
Definition
OAuthConfig.hpp:27
kurlyk::OAuthConfig::client_secret
std::string client_secret
Client secret (optional, usually empty for public/PKCE clients).
Definition
OAuthConfig.hpp:20
kurlyk::OAuthConfig::redirect_uri
std::string redirect_uri
Registered redirect URI.
Definition
OAuthConfig.hpp:23
kurlyk::OAuthConfig::audience
std::string audience
Optional audience parameter.
Definition
OAuthConfig.hpp:26
kurlyk::OAuthConfig::client_id
std::string client_id
OAuth2 client identifier.
Definition
OAuthConfig.hpp:19
kurlyk::OAuthConfig::access_type
std::string access_type
Optional access_type parameter (e.g. "offline").
Definition
OAuthConfig.hpp:28
kurlyk::OAuthConfig::use_pkce
bool use_pkce
Whether to use PKCE (RFC 7636). Default true.
Definition
OAuthConfig.hpp:25
kurlyk::OAuthConfig::authorization_endpoint
std::string authorization_endpoint
Authorization server URL.
Definition
OAuthConfig.hpp:21
kurlyk::OAuthConfig::token_endpoint
std::string token_endpoint
Token exchange URL.
Definition
OAuthConfig.hpp:22
kurlyk::OAuthConfig::scope
std::string scope
Space-separated requested scopes.
Definition
OAuthConfig.hpp:24
include
kurlyk
http
auth
data
OAuthConfig.hpp
Generated by
1.17.0