OAuth 2 error for POST /2/tweets FIXED
See original GitHub issueI am using the latest version of twitter-lite
I thought we were using oAuth 1.0a, but I get this error:
{
_headers: Headers {
[Symbol(map)]: [Object: null prototype] {
'set-cookie': [Array],
'content-type': [Array],
'cache-control': [Array],
'content-length': [Array],
'x-response-time': [Array],
'x-connection-hash': [Array],
date: [Array],
server: [Array],
connection: [Array]
}
},
title: 'Unsupported Authentication',
detail: 'Authenticating with OAuth 2.0 Application-Only is forbidden for this endpoint. Supported authentication types are [OAuth 1.0a User Context, OAuth 2.0 User Context].',
type: 'https://api.twitter.com/2/problems/unsupported-authentication',
status: 403
}
Here is the code
async function createNewTwitterClient (subdomain, extension, response, twitterAppConfig, version) {
const twitter = require("twitter-lite");
return new twitter({
subdomain,
consumer_key: twitterAppConfig.consumerKey, // from Twitter.
consumer_secret: twitterAppConfig.consumerSecret,
extension, // true is the default (this must be set to false for v2 endpoints),
access_token_key: twitterAppConfig.accessTokenKey, // from your User (oauth_token)
access_token_secret: twitterAppConfig.accessTokenSecret, // from your User (oauth_token_secret)
bearer_token: response ? response?.access_token : null,
version
});
}
const apiClient = await createNewTwitterClient('api', false, null, twitterAppConfig,'2');
const apiResponse = await apiClient.getBearerToken();
const twitterApiClient = await createNewTwitterClient('api', false, apiResponse, twitterAppConfig,'2');
twitterApiClient.post('tweets', { text: 'hello world' }).then(tweet => {
// do something
}).catch();
In Postman, it works fine:
Issue Analytics
- State:
- Created 2 years ago
- Comments:15
Top Results From Across the Web
403 error when trying to POST to /2/tweets using example in ...
I'm following the example curl command at POST /2/tweets | Docs | Twitter ... Supported authentication types are [OAuth 1.0a User Context, OAuth...
Read more >OAuth 2 Request Example · Issue #149 · g8rswimmer/go-twitter
Hi, I was trying to post a tweet. It seems like I would need to make use of the OAuth 2 authorization flow....
Read more >'Unsupported Authentication', detail ... - Stack Overflow
The error message. Authenticating with OAuth 2.0 Application-Only. Indicates that the bearer token sent in the API request represents the ...
Read more >OAuth 2.0 App-Only (Bearer Token) | Docs - Twitter Developer
App only authentication and OAuth 2.0 Bearer Token ... An application makes a request to the POST oauth2/token endpoint to exchange ... Common...
Read more >OAuth2 and Twitter API - Questions - n8n community
Describe the issue/error/question Hello, First of all, to present you the context: I need to use the API v2 of twitter But I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
All I know is that the current Twitter-lite V2
/tweets
endpoint does NOT work.My PR code updates, work with me.
I must say your content type error message, is a little strange.
God, this MarkDown Editor is terrible. You would think GitHub could sort this out? 😩