Skip to content

ooojustin/ai-connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-connect

A Rust library for authenticating with AI provider subscriptions using OAuth 2.0 + PKCE.

Supported Providers

  • Anthropic (Claude Code)
  • OpenAI (Codex)

Installation

[dependencies]
ai-connect = { version = "0.1", features = ["local-server"] }

Usage

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"
  }
}

About

A Rust library for authenticating with AI provider subscriptions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages