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
Oauth2 fails to authenticate #2021
Comments
I've just found the way to workaround this. Before performing the redirect to the authorization uri, I store the ._client.code_verifier on the browser session, so, when the callback uri is called I get this value and set it again on its place before calling fetch_token. I hope there is a better a way, this solution looks a bit ugly to me. I had to do something like this: |
Hey, I have the same issue. Is "code_verifier in "oauth2_user_handler._client.code_verifier = request.session["code_verifier"]" supposed to be the code parameter in the callback url? |
Maybe make sure you got the right Twitter dev access? I remember having a similar issue when I didn't have the research access. |
Hi,
I have the same issue that was mentioned in issue #2014. It was closed but was not solved.
After granting the app the permissions, the user is redirected to the callback url with two parameters: state and code.
When passing the full URL to the fetch_token method:
fetch_token("https://mydomain.tld/mycallbackuri/?state=CfVn3zt150Z673dUu8rKLDYvX&code=QlR2VjFxVTYXXXXXXXXXXXXXXXXXMTW5rc3VXXXXXXXXXXxExLOjE2Njg5ODI3MDUyNTI6MTowOmFjOjE")
This error is returned:
InvalidClientIdError: (invalid_request) Missing required parameter [code_verifier]
I was digging a bit and fount this specific line in the stacktrace:
File XXXXXXX/site-packages/tweepy/auth.py:217, in OAuth2UserHandler.fetch_token(self, authorization_response)
return super().fetch_token(
218 "https://api.twitter.com/2/oauth2/token",
219 authorization_response=authorization_response,
220 auth=self.auth,
221 include_client_id=True,
222 code_verifier=self._client.code_verifier
223 )
I can see that self._client.code_verifier is passed as code_verifier, but if I check the actual value of this variable is empty.
Can't see what am I doing wrong? Or if this is an issue?
The text was updated successfully, but these errors were encountered: