0

In my Flask App, I'm using the Python requests-oauthlib library to make OAuth1 requests (https://requests-oauthlib.readthedocs.io/en/latest/oauth1_workflow.html#). One of the API calls that I need to make require passing the 'diffie_hellman_challenge' parameter in the authorization header. From the documentation, I do not see anything about adding custom parameters to the authorization header. Is there a way or another OAuth1 library that I can use to add a custom parameter? My code is as follows:

 from requests_oauthlib import OAuth1

 headeroauth = OAuth1(oauth_consumer_key, signature_method='RSA-SHA256', rsa_key=private_signing_key, signature_type='auth_header', diffie_hellman_challenge=dhChallenge)

 response = requests.post(url, auth=headeroauth)

Unfortunately, the server responds with the following error:

 TypeError: __init__() got an unexpected keyword argument 'diffie_hellman_challenge'
Vee
  • 1,821
  • 3
  • 36
  • 60
  • Looks like you have a different version of the library. Try removing the parameter `diffie_hellman_challenge` – Gonzalo Odiard Apr 01 '22 at 23:12
  • Removing the parameter 'diffie_hellman_challenge' does fix the error but I need to include that parameter in the authorization header for the particular API request that the app is calling. Any suggestions for how I can add that parameter into the authorization header? – Vee Apr 02 '22 at 02:32
  • No idea. The only reference that I found searching is this https://docs.authlib.org/en/latest/specs/rfc7636.html but that looks like is for the server side. Maybe this https://docs.authlib.org/en/latest/client/api.html#authlib.integrations.requests_client.OAuth2Session.create_authorization_url could help? – Gonzalo Odiard Apr 02 '22 at 16:51

0 Answers0