Skip to main content

build_jwt

Function build_jwt 

Source
pub fn build_jwt(claims_json: &str, secret: &[u8]) -> String
Available on crate feature auth only.
Expand description

Build a signed HS256 JWT from a JSON claims object.

Useful for generating test tokens or issuing tokens from a login handler.

use rust_web_server::auth::build_jwt;

let token = build_jwt(r#"{"sub":"42","exp":9999999999}"#, b"secret");