Expand description
Patreon API client library.
This crate provides two clients:
PatreonUserClient: user-facing client for accessing user data after OAuth authorizationPatreonCreatorClient: server-side client for creators to access campaigns, members, and posts
§Examples
§User API (after OAuth authorization)
ⓘ
use patreon::{PatreonUserClient, oauth::OAuthClient};
// 1) Generate an authorization URL
let oauth_client = OAuthClient::new(
"your_client_id",
"your_client_secret",
"https://your-app.com/callback",
);
let auth_url = oauth_client.authorization_url(&["identity", "identity.memberships"]);
// 2) Exchange the authorization code for an access token (from your redirect handler)
let token = oauth_client.exchange_code("authorization_code").await?;
// 3) Use the user client
let user_client = PatreonUserClient::new(&token.access_token);
let identity = user_client.identity().await?;§Server API (creator token)
ⓘ
use patreon::PatreonCreatorClient;
let creator_client = PatreonCreatorClient::new("creator_access_token");
let campaigns = creator_client.campaigns().await?;
let members = creator_client.campaign_members("campaign_id").await?;Re-exports§
pub use error::Error;pub use error::Result;pub use oauth::OAuthClient;pub use user_client::PatreonUserClient;pub use creator_client::PatreonCreatorClient;pub use webhook::WebhookValidator;pub use models::*;
Modules§
- creator_
client - Server API client (creator client).
- error
- Error types.
- models
- Patreon API data models.
- oauth
- OAuth authentication module.
- user_
client - User API client.
- webhook
- Webhook validation and parsing utilities.
Constants§
- API_
BASE_ URL - Patreon API base URL.
- OAUTH_
AUTHORIZE_ URL - Patreon OAuth authorization endpoint URL.
- OAUTH_
TOKEN_ URL - Patreon OAuth Token URL