-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing required parameter [code_verifier] #25
Comments
I am having this exact same issue. The only thing I can think is that the oAuth has a different code_verifier value than my redirect URL for the callback-->both use new auth.OAuth2User to create a client for use on either oAuth or the callback (which is slightly different than what the example code is doing in an app). This is just speculation though. |
Thanks @RodionChachura, you need to call |
@wmencoder thats right, you need to use the same Auth Client that generated the authentication URL |
I am having the same issue, but this solution will not work for me. Is there a way to generate an access token statelessly? My app runs in a serverless environment and I can't persist an instance of the OAuth2User class between requests. I can store any data necessary, but the code_verifier property is private and it can't be accessed from outside the class. EDIT: I have resolved the issue by passing my own code_challenge and setting the code_challenge_method as 'plain'. I then store the code_challenge and generate another authURL with the same code_challenge before generating the access token. I hope that helps if anyone else is in the same situation. |
@sasivarnan The solution was fairly simple. |
@sasivarnan I was able to generate a stateless client by creating a class
That overloads the constructor and assigns the Token that I pass as a cookie from the client. You can theoretically do the same with the code_verifier property instead of doing void call to generateAuthURL to populate that property. This is a hack and clearly this SDK isn't designed for statelessness at this time. |
Feels crazy hacky but works |
I created a PR to solve this issue, I need to work with the maintainers to get a code review and eventually this feature can be merge, the PR is here if you want to take a look: |
The
Using firebase functions, my simplified code is:
|
@pdandradeb what is |
|
My implementation is almost exactly the same except using an onCall instead of on request, in hopes of limiting the ability for this function to be called from any browser. |
This thread was super helpful! Got me past a few roadblocks while trying to use this sdk with nextjs and serverless api functions |
This SDK is very problematic. https://gist.github.com/amemiya/14f1614819210b8be5d4afcbf4727ca6 |
crashes with
I think the problem is that
#codeVerifier
isundefined
here 👇https://github.com/twitterdev/twitter-api-typescript-sdk/blob/0d4954c675dbfc566c6911adc4d4178dce926ca4/src/OAuth2User.ts#L170
The text was updated successfully, but these errors were encountered: