My JavaScript app uses NPM Twit to post on Twitter. Suddenly, my bot stopped working with no explanation. It turns out that Twitter required me to switch to their new free tier and I had to delete all content from my Twitter Dev account and recreate my project and app with read and write permissions.
Authorization is in place as
twitClient.get('account/verify_credentials', {…})
returns all account details successfully.
However, there seems to be a barrier preventing my code from tweeting. When I use
twitClient.post('statuses/update', {…}, function (error, success) {})
, I get the error message:
Post to Twitter failure: Error: You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product
at exports.makeTwitError (/Users/…/node_modules/twit/lib/helpers.js:74:13)
at onRequestComplete (/Users/…/node_modules/twit/lib/twitter.js:344:25)
at Request.<anonymous> (/Users/…/node_modules/twit/lib/twitter.js:364:7)
at Request.emit (node:events:523:35)
at Gunzip.<anonymous> (/Users/…/node_modules/request/request.js:1076:12)
at Object.onceWrapper (node:events:625:28)
at Gunzip.emit (node:events:511:28)
at endReadableNT (node:internal/streams/readable:1367:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 453,
allErrors: [
{
message: 'You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product',
code: 453
}
],
twitterReply: { errors: [ [Object] ] },
statusCode: 403
}
Exploring alternatives, I attempted to switch to Twitter API V2, but it has a completely different syntax for tweeting.
I searched for solutions, but most of what I found was Python code.