how to verify jwk token in rust

  Kiến thức lập trình

I am trying to verify jwt token in rust, but the verify always failed, this is the minimal reproduce demo:

use rust_wheel::model::user::{
    jwt_auth::{create_access_token, verify_jwt_token},
    web_jwt_payload::WebJwtPayload,
};

fn main() {
    let payload = WebJwtPayload {
        userId: 1,
        deviceId: "1".to_owned(),
        appId: "1".to_owned(),
        lt: 0,
        et: 0,
        pid: 1,
    };
    let token = create_access_token(&payload);
    let suc = verify_jwt_token(&token.as_str());
    print!("{}", suc);
}

this is the Cargo.toml:

[package]
name = "rust-learn"
version = "0.1.0"
edition = "2018"

[dependencies]
serde = { version = "1.0.64", features = ["derive"] }
serde_json = "1.0.64"
rust_wheel = { git = "https://github.com/jiangxiaoqiang/rust_wheel.git", branch = "main", features = [
    "model",
    "common",
    "rwconfig",
    "texhub"
] }

and the environment variable is JWT_SECRET=abc. The result always return false. Am I missing something? what should I do to fixed this issue?

LEAVE A COMMENT