Skip to content

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 --- SecretStore trait wrapping Keychain, Credential Manager, etc.
  • Cloud Connector Trait --- CloudConnector interface 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 generation
  • url --- URL parsing for OAuth redirects
  • reqwest (optional, http feature) --- HTTP-based token exchange

Feature Flags

FlagDescription
httpEnables 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 tokens

API Reference

Core Types

TypeDescription
OAuthFlowDrives the OAuth2 authorization code + PKCE flow
OAuthConfigClient ID, redirect URI, scopes, endpoints
OAuthTokensAccess token, refresh token, expiry
TokenRequestHTTP request descriptor for token exchange
ServiceStatusConnection status for a cloud service
ConnectorItemA file or folder from a cloud service
ConnectorErrorCrate error type

Key Traits

TraitDescription
SecretStorePlatform-specific secret storage (Keychain, etc.)
CloudConnectorCloud service integration (list, read, sync)
InMemorySecretStoreIn-memory implementation for testing

Released under the MIT License.