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.28k stars 176 forks source link

Value passed for the authorization code was invalid. #496

Open karanpokar opened 1 year ago

karanpokar commented 1 year ago

Describe the bug Getting Error while OAuth Followed the documentation and getting this in the response. It worked for the first time and getting this for the rest of the tries.

Confidential Client

To Reproduce Please indicate all steps that lead to this bug:

  1. const client = new TwitterApi({ clientId: 'Client', clientSecret: 'Secret' });
  2. client.loginWithOAuth2({ code:code from redirect url, codeVerifier:codeVerifier from generateOAuth2AuthLink , redirectUri: 'http://localhost:3000/twitter' })
  3. data: { error: 'invalid_request', error_description: 'Value passed for the authorization code was invalid.', errors: [ [Object] ] }

Expected behavior Returns UserObject and Accesstoken

Version

RitikDeqode commented 9 months ago

I am also facing the same issue. Did you find any solution for this?

netwarp commented 7 months ago

We have all the same issue...

clearloop commented 7 months ago
  1. the following API is deprecated, see June 26 2023 in the Twitter API ChangeLog
  2. the issue could be caused by requesting an unsupported interface, for example, ur requesting currentUserV2 but you forgot to add users.read to the scope of the client config
tus512 commented 7 months ago

In my case, remove 'offline.access' from scope array when generate auth link and it will work. But the response will not has refresh token, only access token.