| Crates.io | ai-connect |
| lib.rs | ai-connect |
| version | 0.1.0 |
| created_at | 2026-01-11 19:01:57.682498+00 |
| updated_at | 2026-01-11 19:01:57.682498+00 |
| description | Connect to AI provider accounts via OAuth 2.0 + PKCE. Supports Anthropic, OpenAI, and custom providers. |
| homepage | |
| repository | https://github.com/ooojustin/ai-connect |
| max_upload_size | |
| id | 2036235 |
| size | 105,828 |
A Rust library for authenticating with AI provider subscriptions using OAuth 2.0 + PKCE.
[dependencies]
ai-connect = { version = "0.1", features = ["local-server"] }
Code:
use ai_connect::{AnthropicProvider, OAuthError};
#[tokio::main]
async fn main() -> Result<(), OAuthError> {
let auth = AnthropicProvider::authorize(|req| {
println!("Authorization URL: {}", req.url);
Ok(())
})?;
let response = auth.wait().await?;
println!("{}", serde_json::to_string_pretty(&response)?);
Ok(())
}
Output:
{
"access_token": "[REDACTED]",
"refresh_token": "[REDACTED]",
"token_type": "Bearer",
"scope": "user:inference user:profile",
"expires_in": 28800,
"organization": {
"name": "My Organization",
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
"account": {
"email_address": "my@email.net",
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}