Tweepy, having trouble with access token step in OAuth2UserHandler

Viewed 84

I'm following the steps here to edit bookmarks on my own twitter account: https://docs.tweepy.org/en/latest/authentication.html#oauth-2-0-authorization-code-flow-with-pkce-user-context and here: https://improveandrepeat.com/2022/07/python-friday-131-working-with-bookmarks-in-tweepy/

And I'm fine up to the step 'print(oauth2_user_handler.get_authorization_url())' (get authorization url)

But I get stuck at the step 'access_token = oauth2_user_handler.fetch_token( "Authorization Response URL here" )'

What do I need to put there? I've tried copy pasting the url that gets printed, but then I get the error: File "C:\Python310\lib\site-packages\oauthlib\oauth2\rfc6749\parameters.py", line 284, in parse_authorization_code_response raise MissingCodeError("Missing code parameter in response.") oauthlib.oauth2.rfc6749.errors.MissingCodeError: (missing_code) Missing code parameter in response.

Code:

'

import tweepy

oauth2_user_handler = tweepy.OAuth2UserHandler(
    client_id="my client id",
    redirect_uri="https://127.0.0.1:6006/callback",
    scope=["bookmark.read", "bookmark.write", "tweet.read","users.read"],
    
    client_secret="my client secret "
)

print(oauth2_user_handler.get_authorization_url())


verifier = input("Enter whole callback URL: ")

 
access_token = oauth2_user_handler.fetch_token(verifier)

'

Terminal output: terminal output

EDIT (Solved): ugh I put that url generated into a browser then authorize from there. I just have to make the callback url my host or something to access it

0 Answers
Related