Fix examples
This commit is contained in:
parent
6cfb5c7c0e
commit
bae7a12a4b
|
@ -15,13 +15,13 @@ struct Claims {
|
||||||
fn main() {
|
fn main() {
|
||||||
let my_claims =
|
let my_claims =
|
||||||
Claims { sub: "b@b.com".to_owned(), company: "ACME".to_owned(), exp: 10000000000 };
|
Claims { sub: "b@b.com".to_owned(), company: "ACME".to_owned(), exp: 10000000000 };
|
||||||
let key = "secret";
|
let key = b"secret";
|
||||||
|
|
||||||
let mut header = Header::default();
|
let mut header = Header::default();
|
||||||
header.kid = Some("signing_key".to_owned());
|
header.kid = Some("signing_key".to_owned());
|
||||||
header.alg = Algorithm::HS512;
|
header.alg = Algorithm::HS512;
|
||||||
|
|
||||||
let token = match encode(&header, &my_claims, key.as_ref()) {
|
let token = match encode(&header, &my_claims, jwt::Der::from(key)) {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
Err(_) => panic!(), // in practice you would return the error
|
Err(_) => panic!(), // in practice you would return the error
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,8 +15,8 @@ struct Claims {
|
||||||
fn main() {
|
fn main() {
|
||||||
let my_claims =
|
let my_claims =
|
||||||
Claims { sub: "b@b.com".to_owned(), company: "ACME".to_owned(), exp: 10000000000 };
|
Claims { sub: "b@b.com".to_owned(), company: "ACME".to_owned(), exp: 10000000000 };
|
||||||
let key = "secret";
|
let key = b"secret";
|
||||||
let token = match encode(&Header::default(), &my_claims, key.as_ref()) {
|
let token = match encode(&Header::default(), &my_claims, jwt::Hmac::from(key)) {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
Err(_) => panic!(), // in practice you would return the error
|
Err(_) => panic!(), // in practice you would return the error
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue