client.currentUser() gives an error even though client.login() is successful #322
martin-tests
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
const client = new TwitterApi({ appKey: process.env.TWITTER_API_KEY, appSecret: process.env.TWITTER_API_KEY_SECRET, accessToken: authToken, accessSecret: authTokenSecret }); let loggedInClientData = await client.login(authVerifier);
So far so good. After this I want to get the user's details:
const additionalInfo = await client.currentUser();
And this gives me the following error:
ApiResponseError: Request failed with code 401 - Invalid or expired token. (Twitter code 89)
at RequestHandlerHelper.createResponseError (C:\martint\dev\prdx-nuxt\prdx-nuxt\node_modules\twitter-api-v2\dist\client-mixins\request-handler.helper.js:103:16)
at RequestHandlerHelper.onResponseEndHandler (C:\martint\dev\prdx-nuxt\prdx-nuxt\node_modules\twitter-api-v2\dist\client-mixins\request-handler.helper.js:252:25)
at Gunzip.emit (node:events:527:28)
at Gunzip.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
error: true,
type: 'response',
code: 401,
headers: {
date: 'Thu, 07 Jul 2022 14:37:23 GMT',
server: 'tsa_o',
'set-cookie': [
'guest_id=v1%3A165720464304331000; Max-Age=34214400; Expires=Mon, 07 Aug 2023 14:37:23 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None'
],
'content-type': 'application/json; charset=utf-8',
'cache-control': 'no-cache, no-store, max-age=0',
'content-length': '87',
'content-encoding': 'gzip',
'strict-transport-security': 'max-age=631138519',
'x-response-time': '161',
'x-connection-hash': 'f68bf6ea4304ba1b1b28b35e9b436ef8e5051e476b5623b19a88b829e5f3a89c',
connection: 'close'
},
rateLimit: undefined,
data: { errors: [ { code: 89, message: 'Invalid or expired token.' } ] }
}
Beta Was this translation helpful? Give feedback.
All reactions