Fire Auth

Rust wrapper for Firebase Authentication REST API

WTFPL

How to use

First you need to get a web API_KEY from firebase project settings.

```rust let apikey: String = "s6FqaFcRFd...njhB8cCjN7".toowned();

let fireauth = fireauth::FireAuth::new(API_KEY); ```


Features

  1. Sign Up (email)
  2. Sign In (email)
  3. Send OOB Code
  4. Refresh ID Token
  5. Get User Information
  6. Update Email and Password

Don't see what you need? See below for unsupported features for now.


1. Sign Up (email)

```rust let email = "something@email.com".toowned(); let password = "supersecret".toowned(); let returnsecuretoken = true;

match fireauth.signupemail(email, password, returnsecuretoken).await { Ok(response) => ..., Err(error) => ..., }

// response structure struct SignUpResponse { idtoken: String, email: String, refreshtoken: String, expiresin: String, localid: String, } ```

2. Sign In (email)

```rust match fireauth.signinemail(email, password, returnsecuretoken).await { Ok(response) => ..., Err(error) => ..., }

// response structure struct SignInResponse { kind: String, localid: String, email: String, displayname: String, idtoken: String, registered: bool, refreshtoken: Option, expires_in: Option, } ```

3. Send OOB Code

Send verification email

```rust match fireauth.verifyemail(idtoken).await { Ok(sendoobcode) => ... Err(error) => ... }

// response structure struct SendOobCode { kind: String, email: String, } ```

Send reset password

rust match fireauth.reset_password(email).await { Ok(send_oob_code) => ... Err(error) => ... }

4. Refresh ID Token

```rust match fireauth.refreshidtoken(refreshtoken).await { Ok(refreshidtokenresponse) => ... Err(error) => ... }

// response structure struct RefreshIdToken { accesstoken: String, expiresin: String, tokentype: String, refreshtoken: String, idtoken: String, userid: String, project_id: String, } ```

5. Get User Information

```rust match fireauth.getuserinfo(id_token).await { Ok(user) => ..., Err(error) => ..., }

// response structure struct User { localid: String, email: String, passwordhash: String, emailverified: bool, passwordupdatedat: u64, provideruserinfo: Vec, validsince: String, lastloginat: String, createdat: String, lastrefresh_at: String, }

struct ProviderUserInfo { providerid: String, federatedid: String, email: String, raw_id: String, } ```

6. Update Email and Password

Email

```rust match fireauth.changeemail(idtoken, email, false).await { Ok(update_user) => ... Err(error) => ... }

// response structure struct UpdateUser { kind: String, localid: String, email: String, provideruserinfo: Vec, passwordhash: String, emailverified: bool, idtoken: Option, refreshtoken: Option, expiresin: Option, }

struct ProviderUserInfo { providerid: String, federatedid: String, email: String, raw_id: String, } ```

Password

rust match fireauth.change_password(id_token, password, true).await { Ok(update_user) => ... Err(error) => ... }


What are not supported yet

Sign In

Password

User