Skip to main content

get_string_claim

Function get_string_claim 

Source
pub fn get_string_claim(
    token: &str,
    claim: &str,
) -> Result<Option<String>, MantaError>
Expand description

Extract a top-level string claim (e.g. sub) from a JWT token.

Returns None when the claim is absent or is not a string — unlike get_name / get_preferred_username, there is no "MISSING" placeholder, so callers can tell absence apart.

§Errors

Returns MantaError::JwtMalformed when token does not parse as header.payload.signature Base64, or when the payload is not valid UTF-8 JSON.