FeedHive / twitter-api-client

A user-friendly Node.js / JavaScript client library for interacting with the Twitter API.
MIT License
948 stars 84 forks source link

403 on twitter.accountsAndUsers.accountUpdateProfileBanner() #100

Closed baumannzone closed 2 years ago

baumannzone commented 2 years ago

Describe the bug
I'm trying to update the Twitter banner of my user. I've created and tested with both v1 and v2 applications in the developer portal.

Here is my code:

const twitterClient = new TwitterClient({
  apiKey: process.env.API_KEY,
  apiSecret: process.env.API_SECRET,
  accessToken: process.env.CONSUMER_KEY,
  accessTokenSecret: process.env.CONSUMER_SECRET,
});

const uploadBanner = async () => {
  const base64 = fs.readFileSync('1500x500.png', { encoding: 'base64' });
  try {
    await twitterClient.accountsAndUsers.accountUpdateProfileBanner({
      banner: base64,
    });
  } catch (err) {
    console.log(err);
  }
};

To reproduce
Steps to reproduce the behaviour:

The error: { statusCode: 403, data: '' }

Expected behaviour
The banner was successfully updated on Twitter

Package Manager:

Additional context
AFAIK it has to be less than 700kb. The image size I'm using is ~200kb

Edit: I'm starting to think it's related to the app settings and permissions. I managed to get the latest followers. So, the client connection works.

baumannzone commented 2 years ago

Solved. I had to regenerate the tokens after changing them from read-only to read and write.

image