Rust
Rust
Generate OAuth 1.0 Signature
Demonstrates how to generate an OAuth 1.0 signature.Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let _ = false;
let oauth = chilkat::OAuth1::new();
// Set input parameters:
oauth.set_oauth_version("1.0");
oauth.set_oauth_method("GET");
oauth.set_oauth_url("http://echo.lab.madgex.com/echo.ashx");
oauth.set_consumer_key("key");
oauth.set_consumer_secret("secret");
oauth.set_token("accesskey");
oauth.set_token_secret("accesssecret");
oauth.set_nonce("01020304050607080102030405060708");
oauth.set_timestamp("1441659763");
// Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
oauth.set_signature_method("HMAC-SHA256");
if oauth.generate().is_err() {
println!("{}", oauth.last_error_text());
return;
}
// Examine the various outputs:
println!("{}", oauth.query_string());
println!("{}", oauth.base_string());
println!("{}", oauth.hmac_key());
println!("{}", oauth.signature());
println!("{}", oauth.encoded_signature());
println!("{}", oauth.authorization_header());
println!("{}", oauth.generated_url());