iceberg-cpp
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
iceberg::rest::auth::OAuth2Util Class Reference

OAuth2 token and authentication utilities. More...

#include <oauth2_util.h>

Static Public Member Functions

static Result< OAuthTokenResponseFetchToken (HttpClient &client, AuthSession &session, const AuthProperties &properties)
 Fetch an OAuth2 token using the client_credentials grant type.
 
static std::unordered_map< std::string, std::string > AuthHeaders (const std::string &token)
 Build auth headers from a token string.
 
static Result< OAuthTokenResponseExchangeToken (HttpClient &client, AuthSession &session, const std::unordered_map< std::string, std::string > &extra_headers, const std::string &subject_token, const std::string &subject_token_type, const std::optional< std::string > &actor_token, const std::optional< std::string > &actor_token_type, const std::string &scope, const std::string &oauth2_server_uri, const std::unordered_map< std::string, std::string > &optional_params)
 Exchange an OAuth2 token using the RFC 8693 grant type.
 
static std::optional< int64_t > ExpiresAtMillis (std::string_view token)
 Extract expiration time from a JWT token.
 

Detailed Description

OAuth2 token and authentication utilities.

Member Function Documentation

◆ AuthHeaders()

static std::unordered_map< std::string, std::string > iceberg::rest::auth::OAuth2Util::AuthHeaders ( const std::string &  token)
static

Build auth headers from a token string.

Parameters
tokenBearer token string (may be empty).
Returns
Headers map with Authorization header if token is non-empty.

◆ ExchangeToken()

static Result< OAuthTokenResponse > iceberg::rest::auth::OAuth2Util::ExchangeToken ( HttpClient client,
AuthSession session,
const std::unordered_map< std::string, std::string > &  extra_headers,
const std::string &  subject_token,
const std::string &  subject_token_type,
const std::optional< std::string > &  actor_token,
const std::optional< std::string > &  actor_token_type,
const std::string &  scope,
const std::string &  oauth2_server_uri,
const std::unordered_map< std::string, std::string > &  optional_params 
)
static

Exchange an OAuth2 token using the RFC 8693 grant type.

Parameters
clientHTTP client to use for the request.
sessionAuth session for the request headers.
extra_headersRequest headers applied before session authentication.
subject_tokenSubject token to exchange.
subject_token_typeSubject token type.
actor_tokenOptional actor token.
actor_token_typeOptional actor token type.
scopeOAuth2 scope.
oauth2_server_uriToken exchange endpoint.
optional_paramsOptional OAuth parameters.
Returns
The token response or an error.

◆ ExpiresAtMillis()

static std::optional< int64_t > iceberg::rest::auth::OAuth2Util::ExpiresAtMillis ( std::string_view  token)
static

Extract expiration time from a JWT token.

Decodes the JWT payload (base64url) and reads the "exp" claim. Returns std::nullopt if the token is not a valid JWT or has no "exp" claim.

Parameters
tokenA token string containing three dot-separated JWT segments.
Returns
Expiration time as milliseconds since epoch, or std::nullopt.

◆ FetchToken()

static Result< OAuthTokenResponse > iceberg::rest::auth::OAuth2Util::FetchToken ( HttpClient client,
AuthSession session,
const AuthProperties properties 
)
static

Fetch an OAuth2 token using the client_credentials grant type.

Parameters
clientHTTP client to use for the request.
sessionAuth session for the request headers.
propertiesAuth configuration containing credential, scope, token endpoint, and optional OAuth params.
Returns
The token response or an error.

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