Sample code for 30+ languages & platforms
Rust

BrickLink OAuth1 using Chilkat REST

See more BrickLink Examples

Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat REST.

Note: This example requires Chilkat v9.5.0.91 or greater (due to adjustments made within Chilkat to support bricklink OAuth1 needs).

Chilkat Rust Downloads

Rust

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let oauth1 = chilkat::OAuth1::new();

oauth1.set_consumer_key("Your Consumer Key");
oauth1.set_consumer_secret("Your Consumer Secret");
oauth1.set_token("Your OAuth1 Token");
oauth1.set_token_secret("Your Token Secret");
oauth1.set_signature_method("HMAC-SHA1");

let rest = chilkat::Rest::new();

let _ = rest.set_auth_o_auth1(&oauth1, false);

if rest.connect("api.bricklink.com", 443, true, true).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let sb_response = chilkat::StringBuilder::new();
if rest.full_request_no_body_sb("GET", "/api/store/v1/orders?direction=in", &sb_response).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

println!("Response status code = {}", rest.response_status_code());

let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb_response);
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());