Hawk Authorization with actixweb client

I am trying to make a request that uses HAWK authorization for HTTP client
using hawk = "3.2.1" and awc = { version = "3.0.0-beta.18", features = ["rustls"] }
but didnot succed, it says

"Authorization": "Hawk id=\"dh37fgj492je\", ts=\"1642998867\", nonce=\"07dh/rVhhRTKIw==\", mac=\"gGmZ56DHAoWdM4qY0sf+t9wF7BOiBkiaDZJpxErN/2Y=\""
Response Error :{"statusCode":401,"error":"Unauthorized","message":"Bad mac","attributes":{"error":"Bad mac"}}

the code is :

use hawk::{Credentials, Key, PayloadHasher, RequestBuilder, SHA256};

pub async fn useit() {
	let credentials = Credentials {
	    id: "dh37fgj492je".to_string(),
	    key: Key::new("werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn", SHA256).unwrap(),
	};

	let payload_hash = PayloadHasher::new("application/json", SHA256).unwrap().finish().unwrap();
	let payload_hash = &payload_hash[..];

	let request = RequestBuilder::new("GET", "postman-echo.com", 443, "/").hash(payload_hash).request();
	let header = request.make_header(&credentials).unwrap();
	let auth = hawk::Header::new(header.id, header.ts, header.nonce, header.mac, None, None, None, None);
	match auth {
		Ok(auth) => {
			let auth = format!("Hawk {auth}");
			println!("good1: auth: {auth:?}");

			let client = reqwest::Client::new();
			let body = client
				.get("https://postman-echo.com/auth/hawk")
				.header("Authorization", auth)
				.send()
				.await;
			if let Ok(body) = body {
				let text = body.text().await;
				if let Ok(text) = text {
					println!("text is :{}", text);
				}
			}
		},
		Err(e) => println!("{e:?}")
	}	
}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.