Closed ajmas closed 5 years ago
Resolved the issue and sharing for anyone else, assuming the steps are correct:
You need to ensure you pass oauth_token
and oauth_token_secret
to your API server. Then the the constructor is:
const client = new Twitter({
consumer_key: config.twitterConsumerKey,
consumer_secret: config.twitterConsumerSecret,
access_token_key: token,
access_token_secret: tokenSecret
});
This then allowed me to call, the following:
const response = await client.get('account/verify_credentials', {
include_entities: true,
include_email: true
});
Note, from what I can tell there is no notion of 'scope' in Twitter oauth. This means requesting extra data, such as e-mail, needs to be done from the developer console.
The OAuth2 authentication is being handled by a front-end, vue based application, using 'hellojs'. A sample response (real values modified) looks like:
I then try passing the access_token to my API server and use it as follows:
On doing the last call I get:
I did also try with account/verify_credentials:
What is the right property I should be using from Twitter oauth, to pass to the Twitter client?