Auth0 utility to check if the given JWT is valid.
```rust use auth0jwt::getclaims;
async fn main() { let token = env!("JWTTOKEN"); let claims = getclaims(&token).unwrap();
println!("Claims {}", claims); } ```
claims
- Exports the Claims
struct which is useful for deserialization. axum
- Implements the FromRequestParts<T>
trait for Claims
and provides a Token(String)
extractor for convenience.```rust use auth0_jwt::claims::Claims; use axum::{response::IntoResponse, routing::get, Json, Router}; use dotenv::dotenv; use serde::{Deserialize, Serialize}; use std::net::SocketAddr;
async fn main() { dotenv().ok();
// build our application with a route
let app = Router::new().route("/", get(handler));
// run it
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}
struct ResponseBody { message: &'static str, }
struct ClaimsContent { pub exp: usize, pub iat: usize }
async fn handler(Claims(claims): Claims
Json(ResponseBody {
message: "hello world",
})
} ```