An unofficial Rust wrapper around the Stytch for accessing Stytch services.
Cargo.toml
[dependencies]
stytch = "0.2.1"
In your lib or binary crate:
```rs
use stytch::Stytch;
You will first need to create an instance of the Stytch
instance (the client). You are required to provide a PROJECT_ID and
SECRET
If you intend to use Test Environment, use the following:
let project_id = dotenv::var("PROJECT_ID").unwrap();
let secret = dotenv::var("SECRET").unwrap();
// Client
let client = Stytch::new(project_id, secret, Environment::Test);
If you intend to use Live Environment, you can use the following:
let project_id = dotenv::var("PROJECT_ID").unwrap();
let secret = dotenv::var("SECRET").unwrap();
// Client
let client = Stytch::new(project_id, secret, Environment::Live);
- Login or Create
use stytch::{Environment, Stytch, LoginOrCreateParams, Attributes};
// Attributes
let attr = Attributes {
ip_address: "0.0.0.0".into(),
user_agent:"user agent".into()
};
// Login or Create Paramters
let params = LoginOrCreateParams::new("login_magic_url_here",
"signup_magic_url_here",
Some(5),
Some(5),
Some(attr),
Some(true));
// magic links
let res = client
.magic_links()
.email("[email protected]".into())
.login_or_create(params)
.await;
Yasir Shariff
- Twitter: @itsyaasir
- Not affiliated with Stytch.
Copyright © 2021 Yasir Shariff.
This project is MIT licensed.