-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OAuth 2 error for POST /2/tweets FIXED #186
Comments
I have found the fix:
Oh. And I had to update my code as well: Here is the code
So, I removed the bearer token from the twitterAppConfig Maybe, you should be allowed to send the bearer token, along with the access token, without losing the ability to POST. Currently, your code chooses which type of authentication to use, based on whether the bearer token is present. It might be better to choose which type of authentication to use, based on whether the bearer token is present and whether the access token is not present? |
Response:
any fix? @charlesr1971 |
Try adding: subdomain: 'api' To the arguments of: new Twitter({ Argument object... |
Still same response. |
Please try using this exact code: `async function createNewTwitterClient (subdomain, extension, response, twitterAppConfig, version) { const apiClient = await createNewTwitterClient('api', false, null, twitterAppConfig,'2'); twitterApiClient.post('tweets', { text: 'hello world' }).then(tweet => { This works for me! My twitterAppConfig is:
|
Also: **This PR has not been merged yet. ** I had to change the code inside the Twitter-Lite for |
God, this MarkDown Editor is terrible. |
I'm still facing the same issue, I tried the exact same code you mentioned above. |
why there is no content-type application/json? |
Yes. You need to use the twitter-lite version in my PR request above: Unfortunately, the owners of the twitter-lite repo, are not merging PR requests at the moment. But, you can clone my repository and use that: https://github.com/charlesr1971/twitter-lite/tree/%40charlesr1971 |
Here is the commit: |
I tried using your repo for the package but It's also not working. |
All I know is that the current Twitter-lite V2 My PR code updates, work with me. I must say your content type error message, is a little strange. |
Chiming in here to say that I'm also receiving the same content-type error for the try {
const client = new Twitter({
subdomain: "api", // With or without this parameter, the error persists
version: "2",
extension: false,
consumer_key,
consumer_secret,
access_token_key,
access_token_secret,
});
const tweet = await client.post("tweets", {
text: "Hello, World!",
});
res.send({ tweet });
} catch (error) {
res.send({ error });
} Reponds with: {
"error": {
"_headers": {},
"errors": [
{
"message": "Requests with bodies must have content-type of application/json."
}
],
"title": "Invalid Request",
"detail": "One or more parameters to your request was invalid.",
"type": "https://api.twitter.com/2/problems/invalid-request"
}
} @charlesr1971 I will take a look at your PR! |
I am using the latest version of twitter-lite
I thought we were using oAuth 1.0a, but I get this error:
Here is the code
In Postman, it works fine:
The text was updated successfully, but these errors were encountered: