Sample code for 30+ languages & platforms
Dart

ETrade Revoke Access Token

See more ETrade Examples

Revokes an ETrade OAuth access token.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  final http = CkHttp();

  http.oAuth1 = true;
  http.oAuthVerifier = '';
  http.oAuthConsumerKey = 'ETRADE_CONSUMER_KEY';
  http.oAuthConsumerSecret = 'ETRADE_CONSUMER_SECRET';

  // Load the access token previously obtained via the OAuth1 Authorization
  // This is the token that will be revoked.
  final jsonToken = CkJsonObject();
  try {
    jsonToken.loadFile('qa_data/tokens/etrade.json');
  } on ChilkatException {
    print('Failed to load OAuth1 token');
    return;
  }

  http.oAuthToken = jsonToken.stringOf('oauth_token');
  http.oAuthTokenSecret = jsonToken.stringOf('oauth_token_secret');

  final resp = CkHttpResponse();
  try {
    http.httpNoBody('GET', 'https://api.etrade.com/oauth/revoke_access_token', resp);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Make sure a successful response was received.
  if (resp.statusCode != 200) {
    print(resp.statusLine);
    print(resp.header);
    print(resp.bodyStr);
    return;
  }

  // If successful, the resp.BodyStr contains something like this: Revoked Access Token 
  print(resp.bodyStr);

  print('Success.');
}