requests / requests-oauthlib

OAuthlib support for Python-Requests!
https://requests-oauthlib.readthedocs.org/
ISC License
1.71k stars 421 forks source link

Trying to use OAuth1Session with Flickr - requests_oauthlib.oauth1_session.VerifierMissing: No client verifier has been set. #502

Closed smontanaro closed 1 year ago

smontanaro commented 1 year ago

I'm trying to adapt the OAuth1 Workflow documentation to authenticate with the Flickr API. Flickr has a workflow diagram on their site. I wrote the attached script, which is mostly copy/paste of the code from the referenced workflow. I think it follows the Flickr workflow diagram. It seems to work except doesn't return a client verifier. (In particular, I was able to interactively authorize access with the constructed authorization_url.) Here's the output of the successful bits (with suitable elisions):

OAuth1Session: <requests_oauthlib.oauth1_session.OAuth1Session object at 0x7f49065d4b20>
fetch response {'oauth_callback_confirmed': 'true', 'oauth_token': 'blah-blah', 'oauth_token_secret': 'sssh-its-a-secret'}
Please go here and authorize, https://www.flickr.com/services/oauth/authorize?oauth_token=blah-blah
Paste the full redirect URL here: https://www.flickr.com/services/oauth/authorize?oauth_token=blah-blah
oauth response: {'oauth_token': 'blah-blah'}

I get this traceback:

Traceback (most recent call last):
  File "/home/skip/tmp/flickr_oauth.py", line 38, in <module>
    oauth_tokens = oauth.fetch_access_token(access_token_url)
  File "/home/skip/miniconda3/envs/python39/lib/python3.9/site-packages/requests_oauthlib/oauth1_session.py", line 322, in fetch_access_token
    raise VerifierMissing("No client verifier has been set.")
requests_oauthlib.oauth1_session.VerifierMissing: No client verifier has been set.

The Flickr API workflow indicates that it "[r]edirects user back to Application, passing oauth_verifier." Indeed, the returned oauth_response dict lacks an oauth_verifier key:

{'oauth_token': 'blah-blah'}

I know this is really a help request, not a bug report, but I couldn't see anywhere to ask usage questions for this package. Reference to the correct place is welcome, as would information about what I've done wrong.

flickr_oauth.py

smontanaro commented 1 year ago

Figured out my stupidity. I wasn't pasting the redirect URL, but the auth url. :dodo: