itsyaasir / stytch-rs

Unofficial client pacakge for Stytch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stytch Rust

Version Documentation License: MIT

About

An unofficial Rust wrapper around the Stytch for accessing Stytch services.

Install

Cargo.toml

[dependencies]
stytch = "0.2.1"

In your lib or binary crate:

```rs
use stytch::Stytch;

Usage

Creating a Stytch client

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);

Services

Magic Links

  • 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("test@test.com".into())
   .login_or_create(params)
   .await;

More Examples will be added

Author

Yasir Shariff

Copyright © 2021 Yasir Shariff.
This project is MIT licensed.

About

Unofficial client pacakge for Stytch


Languages

Language:Rust 100.0%