spt-connectors
Platform-agnostic cloud connector framework for OAuth2 and service integrations
Overview
spt-connectors provides an OAuth2 authorization code flow with PKCE and a pluggable connector framework for integrating cloud services (Dropbox, Microsoft Graph, etc.) into SmartBrain. Platform-specific concerns like browser opening, secret storage, and HTTP execution are abstracted behind traits that each platform implements.
Key Features
- OAuth2 + PKCE --- full authorization code flow with proof key for code exchange
- Pluggable Secret Storage ---
SecretStoretrait wrapping Keychain, Credential Manager, etc. - Cloud Connector Trait ---
CloudConnectorinterface per service for listing, reading, syncing - Dropbox Connector --- stub connector for Dropbox file access
- Microsoft Graph Connector --- stub connector for OneDrive/Outlook via Graph API
Dependencies
Key external dependencies:
sha2/base64/rand--- PKCE challenge generationurl--- URL parsing for OAuth redirectsreqwest(optional,httpfeature) --- HTTP-based token exchange
Feature Flags
| Flag | Description |
|---|---|
http | Enables reqwest-based token exchange in OAuthFlow |
Usage
rust
use spt_connectors::{OAuthFlow, OAuthConfig, SecretStore, InMemorySecretStore};
let config = OAuthConfig { /* ... */ };
let flow = OAuthFlow::new(config);
let auth_url = flow.authorization_url();
// redirect user, then exchange code for tokensAPI Reference
Core Types
| Type | Description |
|---|---|
OAuthFlow | Drives the OAuth2 authorization code + PKCE flow |
OAuthConfig | Client ID, redirect URI, scopes, endpoints |
OAuthTokens | Access token, refresh token, expiry |
TokenRequest | HTTP request descriptor for token exchange |
ServiceStatus | Connection status for a cloud service |
ConnectorItem | A file or folder from a cloud service |
ConnectorError | Crate error type |
Key Traits
| Trait | Description |
|---|---|
SecretStore | Platform-specific secret storage (Keychain, etc.) |
CloudConnector | Cloud service integration (list, read, sync) |
InMemorySecretStore | In-memory implementation for testing |