Function jsonwebtoken::dangerous_unsafe_decode [−][src]
pub fn dangerous_unsafe_decode<T: DeserializeOwned>(
token: &str
) -> Result<TokenData<T>>
Decode a token without any signature validation into a struct containing 2 fields: claims
and header
.
NOTE: Do not use this unless you know what you are doing! If the token's signature is invalid, it will not return an error.
ⓘThis example is not tested
#[macro_use] extern crate serde_derive; use jsonwebtoken::{dangerous_unsafe_decode, Validation, Algorithm}; #[derive(Debug, Serialize, Deserialize)] struct Claims { sub: String, company: String } let token = "a.jwt.token".to_string(); // Claims is a struct that implements Deserialize let token_data = dangerous_unsafe_decode::<Claims>(&token, &Validation::new(Algorithm::HS256));