Sample code for 30+ languages & platforms
Rust

ETrade Revoke Access Token

See more ETrade Examples

Revokes an ETrade OAuth access token.

Chilkat Rust Downloads

Rust

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

let http = chilkat::Http::new();

http.set_o_auth1(true);
http.set_o_auth_verifier("");
http.set_o_auth_consumer_key("ETRADE_CONSUMER_KEY");
http.set_o_auth_consumer_secret("ETRADE_CONSUMER_SECRET");

// Load the access token previously obtained via the OAuth1 Authorization
// This is the token that will be revoked.
let json_token = chilkat::JsonObject::new();
if json_token.load_file("qa_data/tokens/etrade.json").is_err() {
    println!("Failed to load OAuth1 token");
    return;
}

http.set_o_auth_token(&json_token.string_of("oauth_token").unwrap_or_default());
http.set_o_auth_token_secret(&json_token.string_of("oauth_token_secret").unwrap_or_default());

let resp = chilkat::HttpResponse::new();
if http.http_no_body("GET", "https://api.etrade.com/oauth/revoke_access_token", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

// Make sure a successful response was received.
if resp.status_code() != 200 {
    println!("{}", resp.status_line());
    println!("{}", resp.header());
    println!("{}", resp.body_str());
    return;
}

// If successful, the resp.BodyStr contains something like this: Revoked Access Token 
println!("{}", resp.body_str());

println!("Success.");