React Native
React Native
ETrade Revoke Access Token
See more ETrade Examples
Revokes an ETrade OAuth access token.Chilkat React Native Downloads
import { Http, HttpResponse, JsonObject } from '@chilkat/react-native'
async function chilkatExample() {
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
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.
const jsonToken = new JsonObject();
try {
jsonToken.loadFile('qa_data/tokens/etrade.json');
} catch {
console.log('Failed to load OAuth1 token');
return;
}
http.oAuthToken = jsonToken.stringOf('oauth_token');
http.oAuthTokenSecret = jsonToken.stringOf('oauth_token_secret');
const resp = new HttpResponse();
try {
await http.httpNoBodyAsync('GET', 'https://api.etrade.com/oauth/revoke_access_token', resp);
} catch {
console.log(http.lastErrorText);
return;
}
// Make sure a successful response was received.
if (resp.statusCode !== 200) {
console.log(resp.statusLine);
console.log(resp.header);
console.log(resp.bodyStr);
return;
}
// If successful, the resp.BodyStr contains something like this: Revoked Access Token
console.log(resp.bodyStr);
console.log('Success.');
}