twitter-lite
twitter-lite copied to clipboard
Can't authenticate
The authentication works perfectly with twit, but with twitter-lite all the request I tried were denied.
I used the basic example.
If I do the user authentication as following:
client = new Twitter({ consumer_key, consumer_secret, access_token, access_token_secret });
The output is:
{ _headers: Headers { [Symbol(map)]: [Object: null prototype] { 'cache-control': [Array], connection: [Array], 'content-encoding': [Array], 'content-length': [Array], 'content-type': [Array], date: [Array], server: [Array], 'set-cookie': [Array], 'strict-transport-security': [Array], 'x-connection-hash': [Array], 'x-response-time': [Array] } }, errors: [ { code: 89, message: 'Invalid or expired token.' } ] }
If I include the bearer_token
in the constructor, the output is this:
{ _headers: Headers { [Symbol(map)]: [Object: null prototype] { 'cache-control': [Array], connection: [Array], 'content-encoding': [Array], 'content-length': [Array], 'content-type': [Array], date: [Array], server: [Array], 'set-cookie': [Array], 'strict-transport-security': [Array], 'x-connection-hash': [Array], 'x-response-time': [Array] } }, errors: [ { message: 'Your credentials do not allow access to this resource', code: 220 } ] }
Yep, same here as well.
I got the same issue reported, however, not all my requests failed, it's just some of them. I wonder whether I should create the client for every API request, instead of using the same client instance for all requests with the same tokens. (To me, ideally, they should be the same, though)
I believe the problem is with the bearer token. Did you place the keyword "Bearer" before the token in your config?
Ah never mind I'm thinking of the wrong library
@wevertor this is an old question but I'm sorting through Issues in the repo, if still relevant, take a look at how I implemented twitterClient
and bearerClient
here: https://github.com/rlueder/tidytweets/blob/main/functions/twitter-client/twitter-client.js