1#ifndef SOURCEMETA_CORE_OAUTH_TOKEN_H_
2#define SOURCEMETA_CORE_OAUTH_TOKEN_H_
4#ifndef SOURCEMETA_CORE_OAUTH_EXPORT
5#include <sourcemeta/core/oauth_export.h>
8#include <sourcemeta/core/crypto.h>
9#include <sourcemeta/core/json.h>
10#include <sourcemeta/core/oauth_authorization.h>
18namespace sourcemeta::core {
39SOURCEMETA_CORE_OAUTH_EXPORT
41 const std::string_view code,
const std::string_view redirect_uri,
42 const std::string_view code_verifier,
43 const std::span<const OAuthParameter> resources,
SecureString &sink)
64SOURCEMETA_CORE_OAUTH_EXPORT
66 const std::string_view refresh_token,
const std::string_view scope,
67 const std::span<const OAuthParameter> resources,
SecureString &sink)
86SOURCEMETA_CORE_OAUTH_EXPORT
88 const std::string_view scope,
89 const std::span<const OAuthParameter> resources,
SecureString &sink)
140SOURCEMETA_CORE_OAUTH_EXPORT
144 const std::function<
void(std::string_view, std::string_view)> &on_other)
172 [[nodiscard]]
auto access_token() const -> std::optional<std::string_view>;
175 [[nodiscard]] auto
token_type() const -> std::optional<std::string_view>;
183 [[nodiscard]] auto
expires_in() const -> std::optional<std::chrono::seconds>;
186 [[nodiscard]] auto
refresh_token() const -> std::optional<std::string_view>;
189 [[nodiscard]] auto
scope() const -> std::optional<std::string_view>;
193 [[nodiscard]] auto
has_scope(const std::string_view value) const ->
bool;
243SOURCEMETA_CORE_OAUTH_EXPORT
259SOURCEMETA_CORE_OAUTH_EXPORT
261 const std::string_view error_description,
262 const std::string_view error_uri) ->
JSON;
std::optional< std::chrono::seconds > expires_in
Definition oauth_token.h:214
std::string_view refresh_token
The refresh token, for the refresh grant (RFC 6749 Section 6).
Definition oauth_token.h:110
OAuthTokenResponse(const JSON &data)
Construct a view over a token response document, which is borrowed.
auto data() const -> const JSON &
std::string_view redirect_uri
Definition oauth_token.h:106
std::string_view code
Definition oauth_token.h:103
std::string_view scope
The space-delimited requested scope (RFC 6749 Section 3.3).
Definition oauth_token.h:112
std::string_view requested_scope
Definition oauth_token.h:224
auto is_bearer_token_type() const -> bool
std::string_view access_token
The issued access token (RFC 6749 Section 5.1).
Definition oauth_token.h:209
std::string_view grant_type
The grant type (RFC 6749 Section 4.1.3).
Definition oauth_token.h:100
auto scope() const -> std::optional< std::string_view >
The granted scope (RFC 6749 Section 5.1), or no value when absent.
auto token_type() const -> std::optional< std::string_view >
The access token type (RFC 6749 Section 5.1), or no value when absent.
auto has_scope(const std::string_view value) const -> bool
auto access_token() const -> std::optional< std::string_view >
The issued access token (RFC 6749 Section 5.1), or no value when absent.
auto refresh_token() const -> std::optional< std::string_view >
The issued refresh token (RFC 6749 Section 5.1), or no value when absent.
auto expires_in() const -> std::optional< std::chrono::seconds >
std::string_view token_type
The token type, such as Bearer (RFC 6749 Section 7.1).
Definition oauth_token.h:211
std::string_view code_verifier
The PKCE code verifier (RFC 7636 Section 4.5).
Definition oauth_token.h:108
std::string_view refresh_token
The issued refresh token, omitted when absent (RFC 6749 Section 5.1).
Definition oauth_token.h:216
std::string_view scope
Definition oauth_token.h:221
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_token_error_response(const std::string_view error, const std::string_view error_description, const std::string_view error_uri) -> JSON
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_make_token_response(const OAuthTokenGrant &grant) -> JSON
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_token_request_refresh(const std::string_view refresh_token, const std::string_view scope, const std::span< const OAuthParameter > resources, SecureString &sink) -> void
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_token_request_client_credentials(const std::string_view scope, const std::span< const OAuthParameter > resources, SecureString &sink) -> void
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_parse_token_request(const std::string_view body, SecureString &storage, OAuthTokenRequest &result, const std::function< void(std::string_view, std::string_view)> &on_other) -> bool
SOURCEMETA_CORE_OAUTH_EXPORT auto oauth_build_token_request_code(const std::string_view code, const std::string_view redirect_uri, const std::string_view code_verifier, const std::span< const OAuthParameter > resources, SecureString &sink) -> void