node-twitter-api-v2 icon indicating copy to clipboard operation
node-twitter-api-v2 copied to clipboard

Value passed for the authorization code was invalid.

Open karanpokar opened this issue 2 years ago • 5 comments

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

  • 16.13.0
  • Lib version: 1.15.1
  • macOS 13.1 (22C65) Screenshot 2023-08-24 at 1 21 02 PM Screenshot 2023-08-24 at 1 23 06 PM

karanpokar avatar Aug 24 '23 07:08 karanpokar

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

RitikDeqode avatar Dec 18 '23 08:12 RitikDeqode

We have all the same issue...

Cryptomancien avatar Mar 04 '24 16:03 Cryptomancien

  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

clearloop avatar Mar 04 '24 18:03 clearloop

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.

tus512 avatar Mar 06 '24 09:03 tus512