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()),
};
// 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: Client
The underlying HTTP client for making requests.
config: ClientConfig
Client configuration including key paths and identifiers.
signing_key: SigningKey
The 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
OpClientError::Signature
if the signing key cannot be loaded or generatedOpClientError::Signature
if JWKS cannot be saved to the specified path
Trait Implementations§
Source§impl AuthenticatedResources for AuthenticatedOpenPaymentsClient
impl AuthenticatedResources for AuthenticatedOpenPaymentsClient
fn quotes(&self) -> QuoteResource<'_>
fn incoming_payments(&self) -> IncomingPaymentResource<'_>
fn outgoing_payments(&self) -> OutgoingPaymentResource<'_>
fn grant(&self) -> Grant<'_>
fn token(&self) -> Token<'_>
Source§impl BaseClient for AuthenticatedOpenPaymentsClient
impl BaseClient for AuthenticatedOpenPaymentsClient
Source§fn http_client(&self) -> &ReqwestClient
fn http_client(&self) -> &ReqwestClient
Returns a reference to the underlying reqwest HTTP client.
Auto Trait Implementations§
impl Freeze for AuthenticatedOpenPaymentsClient
impl !RefUnwindSafe for AuthenticatedOpenPaymentsClient
impl Send for AuthenticatedOpenPaymentsClient
impl Sync for AuthenticatedOpenPaymentsClient
impl Unpin for AuthenticatedOpenPaymentsClient
impl !UnwindSafe for AuthenticatedOpenPaymentsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more