pub async fn verify_token(
    uid: &str,
    client_token: &str
) -> Result<TokenData<Claims>, Box<dyn Error>>
Expand description

Verify Firebase client token by passing the uid and client token.

Prerequisites:

  • Please add env variable “FIREBASE_PROJECT_ID=your-firebase-project-id”

Examples

use firebase_jwt_rs::*;


async fn fetch_token() {
    let uid = "your-uid";
    let client_token = "your-client-token";
    // Get your uid and client token from official Firebase Client SDK:
    // https://firebase.google.com/docs/auth/admin/verify-id-tokens#retrieve_id_tokens_on_clients
    let result = verify_token(uid, client_token).await;

    match result {
        Ok(res) => {
            let text: String = serde_json::to_string(&res.claims).unwrap();
            println!("result:{text}");
        }
        Err(e) => {
            println!("err:{e}");
        }
    }
}