Go
Go
ETrade Revoke Access Token
See more ETrade Examples
Revokes an ETrade OAuth access token.Chilkat Go Downloads
success := false
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := chilkat.NewHttp()
http.SetOAuth1(true)
http.SetOAuthVerifier("")
http.SetOAuthConsumerKey("ETRADE_CONSUMER_KEY")
http.SetOAuthConsumerSecret("ETRADE_CONSUMER_SECRET")
// Load the access token previously obtained via the OAuth1 Authorization
// This is the token that will be revoked.
jsonToken := chilkat.NewJsonObject()
success = jsonToken.LoadFile("qa_data/tokens/etrade.json")
if success != true {
fmt.Println("Failed to load OAuth1 token")
http.DisposeHttp()
jsonToken.DisposeJsonObject()
return
}
http.SetOAuthToken(jsonToken.StringOf("oauth_token"))
http.SetOAuthTokenSecret(jsonToken.StringOf("oauth_token_secret"))
resp := chilkat.NewHttpResponse()
success = http.HttpNoBody("GET","https://api.etrade.com/oauth/revoke_access_token",resp)
if success == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
jsonToken.DisposeJsonObject()
resp.DisposeHttpResponse()
return
}
// Make sure a successful response was received.
if resp.StatusCode() != 200 {
fmt.Println(resp.StatusLine())
fmt.Println(resp.Header())
fmt.Println(resp.BodyStr())
http.DisposeHttp()
jsonToken.DisposeJsonObject()
resp.DisposeHttpResponse()
return
}
// If successful, the resp.BodyStr contains something like this: Revoked Access Token
fmt.Println(resp.BodyStr())
fmt.Println("Success.")
http.DisposeHttp()
jsonToken.DisposeJsonObject()
resp.DisposeHttpResponse()