Sample code for 30+ languages & platforms
Lua

ETrade Revoke Access Token

See more ETrade Examples

Revokes an ETrade OAuth access token.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

local http = chilkat.Http.new()

http.oauth1 = true
http.oauth_verifier = ""
http.oauth_consumer_key = "ETRADE_CONSUMER_KEY"
http.oauth_consumer_secret = "ETRADE_CONSUMER_SECRET"

-- Load the access token previously obtained via the OAuth1 Authorization
-- This is the token that will be revoked.
local jsonToken = chilkat.JsonObject.new()
local success = jsonToken:load_file("qa_data/tokens/etrade.json")
if not success then
    print("Failed to load OAuth1 token")
    return
end

http.oauth_token = jsonToken:string_of("oauth_token")
http.oauth_token_secret = jsonToken:string_of("oauth_token_secret")

local resp = chilkat.HttpResponse.new()
success = http:http_no_body("GET", "https://api.etrade.com/oauth/revoke_access_token", resp)
if not success then
    print(http.last_error_text)
    return
end

-- Make sure a successful response was received.
if resp.status_code ~= 200 then
    print(resp.status_line)
    print(resp.header)
    print(resp.body_str)
    return
end

-- If successful, the resp.BodyStr contains something like this: Revoked Access Token
print(resp.body_str)

print("Success.")