tangled-api 0.1.0

Lexicon-generated XRPC client for Tangled and AT Protocol APIs
Documentation
// @generated by `cargo xtask codegen` — do not edit.
// source: lexicons/com/atproto/server/getServiceAuth.json (com.atproto.server.getServiceAuth)

#![allow(clippy::all)]

pub const NSID: &str = "com.atproto.server.getServiceAuth";

#[derive(Debug, Clone, Default, serde::Serialize)]
pub struct Params {
    /// The DID or `did#serviceId` reference of the service that the token will be used to authenticate with.
    pub aud: String,
    /// The time in Unix Epoch seconds that the JWT expires. Defaults to 60 seconds in the future. The service may enforce certain time bounds on tokens depending on the requested scope.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exp: Option<i64>,
    /// Lexicon (XRPC) method to bind the requested token to
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lxm: Option<String>,
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Output {
    pub token: String,
}

/// Get a signed token on behalf of the requesting DID for the requested service.
///
/// Errors:
/// - `BadExpiration`: Indicates that the requested expiration date is not a valid. May be in the past or may be reliant on the requested scopes.
pub fn get_service_auth(
    http: &reqwest::Client,
    base: &str,
    params: &Params,
) -> reqwest::RequestBuilder {
    let rb = http.get(crate::xrpc::xrpc_url(base, NSID));
    let rb = rb.header(reqwest::header::ACCEPT, "application/json");
    let rb = crate::xrpc::push_query(rb, params);
    rb
}