pub struct AuthenticatedOpenPaymentsClient {
pub http_client: Client,
pub config: ClientConfig,
pub signing_key: SigningKey,
}Expand description
An authenticated Open Payments client that can make signed HTTP requests.
This client automatically handles HTTP message signature creation for all requests using the configured private key. It’s used for operations that require authentication such as creating payments, quotes and managing access tokens.
§Example
use open_payments::client::{AuthenticatedClient, ClientConfig, AuthenticatedResources, UnauthenticatedResources};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// In a real application, you would use actual file paths
let config = ClientConfig {
private_key_path: "path/to/private-key.pem".into(),
key_id: "my-key-id".to_string(),
jwks_path: Some("path/to/jwks.json".into()),
wallet_address_url: "https://rafiki.money/alice".into(),
};
// This would fail in a real scenario if the files don't exist
// but demonstrates the API usage
let _client = AuthenticatedClient::new(config)?;
Ok(())
}Fields§
§http_client: ClientThe underlying HTTP client for making requests.
config: ClientConfigClient configuration including key paths and identifiers.
signing_key: SigningKeyThe signing key used for HTTP message signatures.
Implementations§
Source§impl AuthenticatedOpenPaymentsClient
impl AuthenticatedOpenPaymentsClient
Sourcepub fn new(config: ClientConfig) -> Result<Self>
pub fn new(config: ClientConfig) -> Result<Self>
Creates a new authenticated client with the given configuration.
This method will:
- Load or generate the signing key from the specified path
- Generate and save JWKS if a JWKS path is provided
- Create an HTTP client for making requests
§Arguments
config- The client configuration containing key paths and identifiers
§Returns
Returns a configured authenticated client or an error if key loading fails.
§Errors
Returns an OpClientError with:
description: Human-readable error messagestatus: HTTP status text (for HTTP errors)code: HTTP status code (for HTTP errors)validation_errors: List of validation errors (if applicable)details: Additional error details (if applicable)
Sourcepub fn public_jwk(&self) -> JsonWebKey
pub fn public_jwk(&self) -> JsonWebKey
Returns the public JsonWebKey corresponding to this client’s signing key.
Useful for directed-identity grant requests via grant().request(..., Some(&jwk)).