Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
305 stars 31 forks source link

Can't Make Calls with REST ID? "Not Authorized to access requested resource"? Can only retrieve pin tweet from a timeline? #437

Closed TheUltimateAbsol closed 5 months ago

TheUltimateAbsol commented 5 months ago

First time using this API. I'm trying to follow the examples in the guide. Using version 2.4.2. I am using an authenticated API Key from my user login.

I made a call with a username to the details endpoint (So I could find the REST ID)

rettiwt.user.details('alkalinedd')
.then(res => {
    console.log(res);
})
.catch(err => {
    console.log(err);
});

Successfully got the response

User {
  id: '1140826190091116544',
  userName: 'alkalinedd',
  fullName: 'ALKALINEDD',
  createdAt: 'Tue Jun 18 03:38:54 +0000 2019',
  description: '二次創作イラストを描くメイド(主にインテイ) 🌞\n' +
    '目的:毎週1枚投稿 🌟\n' +
    'アニメ私塾で勉強なう✍️\n' +
    '\n' +
    'A maid who draws fan art (Esp works from Inti Creates) 🌞\n' +
    'Current Goal: To post once a week 🌟',
  isVerified: false,
  favouritesCount: 8998,
  followersCount: 436,
  followingsCount: 484,
  statusesCount: 806,
  location: '',
  pinnedTweet: '1744329062028390752',
  profileBanner: undefined,
  profileImage: 'https://pbs.twimg.com/profile_images/1678235052738506753/Zh7o018s_normal.jpg'
}

Alright, so I try plugging in the REST id into the same request:

rettiwt.user.details('1140826190091116544')
.then(res => {
    console.log(res);
})
.catch(err => {
    console.log(err);
});

I get the response

Error: Not authorized to access requested resource
    at UserService.FetcherService.checkAuthorization (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:122:19)
    at UserService.<anonymous> (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:187:30)
    at step (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:33:23)
    at Object.next (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:14:53)
    at C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:4:12)
    at UserService.FetcherService.request (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:180:16)
    at UserService.<anonymous> (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:305:51)
    at step (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:33:23)

When I try to get replies, same thing:

rettiwt.user.replies('1140826190091116544')
.then(res => {
    console.log(res);
})
.catch(err => {
    console.log(err);
});
Error: Not authorized to access requested resource
    at UserService.FetcherService.checkAuthorization (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:122:19)
    at UserService.<anonymous> (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:187:30)
    at step (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:33:23)
    at Object.next (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:14:53)
    at C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:4:12)
    at UserService.FetcherService.request (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:180:16)
    at UserService.<anonymous> (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:305:51)
    at step (C:\Users\thebe\Documents\like-counter\node_modules\rettiwt-api\dist\services\internal\FetcherService.js:33:23)

When I try getting a timeline, I get only a pinned reply:

rettiwt.user.timeline('1140826190091116544', 20)
.then(res => {
    console.log(res);
})
.catch(err => {
    console.log(err);
});
CursoredData {
  list: [
    Tweet {
      id: '1744329062028390752',
      createdAt: 'Mon Jan 08 12:03:51 +0000 2024',
      tweetBy: [User],
      entities: [TweetEntities],
      media: [Array],
      quoted: undefined,
      fullText: '画力アップ✨.←2022年 2020年→ https://t.co/OitciqXsCh.',
      replyTo: undefined,
      lang: 'ja',
      quoteCount: 0,
      replyCount: 1,
      retweetCount: 44,
      likeCount: 182,
      viewCount: 2356,
      bookmarkCount: 4
    }
  ],
  next: Cursor { value: '' }
}

What's going on? Am I using this correctly? Or has there been a wave of breaking changes?

Rishikant181 commented 5 months ago
  1. Did you pass in the API_KEY while instantiating a Rettiwt instance like this: const rettiwt = new Rettiwt({ apiKey: API_KEY })?
  2. If yes, did you try logging in into Twitter Web app using the same Twitter account which was used to generate API_KEY?
TheUltimateAbsol commented 5 months ago

Thanks. turned out that, since I was resuming work on an old project, I didn't notice that the syntax for passing in the API key changed from Rettiwt(API_KEY) to Rettiwt({{ apiKey: API_KEY }).

Sorry for the panic