Crates.io | rp-supabase-auth |
lib.rs | rp-supabase-auth |
version | |
source | src |
created_at | 2024-10-26 09:22:42.400156 |
updated_at | 2024-10-26 11:50:15.317304 |
description | A Rust client library for interacting with Supabase’s Authentication API. |
homepage | https://github.com/roberts-pumpurs/supabase-rs-utils |
repository | https://github.com/roberts-pumpurs/supabase-rs-utils |
max_upload_size | |
id | 1423674 |
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` |
size | 0 |
A Rust client library for interacting with Supabase’s Authentication API.
Features
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");
}