PLhery / node-twitter-api-v2

Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
https://www.npmjs.com/package/twitter-api-v2
Apache License 2.0
1.24k stars 174 forks source link

Issue with client.v2.tweet Function Not Returning Response and Freezing Server #497

Open sampatsharma143 opened 10 months ago

sampatsharma143 commented 10 months ago

I'm encountering an issue with the client.v2.tweet function from the Twitter API library within supabase cloud functions. The problem is that when I use this function to post a tweet, it doesn't seem to return a response as expected, and it leads to the server becoming unresponsive or freezing. but it does post the tweet to my twitter account.

code

const client = userClient.readWrite;
try{
  const postTweet = await client.v2.tweet({text:tweetText});
  // console.log(postTweet )
  return new Response(
    JSON.stringify({
      message: postTweet,
    }),
    { headers: { "Content-Type": "application/json" }, status: 200, },
  );
}catch(e){
  const error = {
    message: e,
  };

  return new Response(
    JSON.stringify(error),
    { headers: { "Content-Type": "application/json" },status:300 },
  );
}

Please let me know if there are any suggestions or potential solutions to resolve this issue. Your assistance is greatly appreciated.

reyou commented 10 months ago

I am getting following error on my free account

 data: {
        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
      }

Do you have free or paid account?