rp-supabase-auth

Crates.iorp-supabase-auth
lib.rsrp-supabase-auth
version
sourcesrc
created_at2024-10-26 09:22:42.400156
updated_at2024-10-26 11:50:15.317304
descriptionA Rust client library for interacting with Supabase’s Authentication API.
homepagehttps://github.com/roberts-pumpurs/supabase-rs-utils
repositoryhttps://github.com/roberts-pumpurs/supabase-rs-utils
max_upload_size
id1423674
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Roberts Pumpurs (roberts-pumpurs)

documentation

README

rp-supabase-auth

A Rust client library for interacting with Supabase’s Authentication API.

Features

  • Comprehensive API Coverage: Supports all Supabase Auth endpoints.
  • Typed Models: Provides strongly-typed request and response models.
  • Asynchronous: Built on top of tokio and reqwest for async operations.
  • JWT Refresh Stream: Automatically refreshes JWT tokens using a stream.
use rp_supabase_auth::auth_client::{new_authenticated_stream, requests};
use rp_supabase_auth::futures::StreamExt as _;
use rp_supabase_auth::jwt_stream::SupabaseAuthConfig;
use rp_supabase_auth::types::LoginCredentials;
use rp_supabase_auth::url;
use futures::StreamExt;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = SupabaseAuthConfig {
        api_key: "your-supabase-api-key".to_string(),
        max_reconnect_attempts: 5,
        reconnect_interval: Duration::from_secs(3),
        url: "https://your-project.supabase.co".parse().unwrap(),
    };
    let login_credentials = LoginCredentials::builder()
        .email("user@example.com".to_string())
        .password("password".to_string())
        .build();

    let mut auth_client_stream = new_authenticated_stream(config, login_credentials).unwrap();
    while let Some(item) = auth_client_stream.next().await {
        tracing::debug!(?item, "new client?");
        let Ok(Ok(client)) = item else {
            continue;
        };
        let result = client
            .build_request(&requests::UserGetRequest)
            .unwrap()
            .execute()
            .await
            .unwrap()
            .json()
            .await
            .unwrap();
        tracing::info!(data =? result, "user info");
    }
    tracing::error!("realtime connection exited");

}
Commit count: 95

cargo fmt