Module verification

Module verification 

Source
Expand description

Verification of an ID token of the Firebase Auth.

See also document.

§NOTICE

This feature is only available when the feature verify is enabled.

§Examples

An example of ID token verification with tokio and anyhow is as follows:

use fars::VerificationConfig;
use fars::ProjectId;
use fars::IdToken;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create a verification config.
    let config = VerificationConfig::new(
        ProjectId::new("firebase-project-id"),
    );

    // Verify the ID token.
    match config.verify_id_token(
        &IdToken::new("id-token"),
    ).await {
        Ok(claims) => {
            // Verification succeeded.
            println!("Token ID verification succeeded: {:?}", claims);
        },
        Err(error) => {
            // Verification failed.
            eprintln!("Token ID verification failed: {:?}", error);
        }
    }

    Ok(())
}