i am currently making oauth 1 signed requests using the requests-oauthlib
library.
from requests_oauthlib import OAuth1Session
self.session = OAuth1Session(
OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET,
oauth_token, oauth_token_secret,
signature_type='auth_header', realm='http://api.twitter.com'
)
self.session.headers = self.default_headers
self.session.verify = self.verify
self.session.proxies.update(self.proxies)
Using this i can successfully make oauth 1 requests. But I need http 2 and would like to use async io. Thats why i am trying to switch to httpx
and authlib
.
from authlib.integrations.httpx_client import OAuth1Client
self.session = OAuth1Client(
OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET,
oauth_token, oauth_token_secret,
http2=True,
headers=self.default_headers,
proxies=self.proxies,
verify=self.context
)
self.session.auth.realm = 'http://api.twitter.com'
With requests-oauthlib
i can make signed requests without a problem. But when i try to do the same with httpx
i get this response:
{
"errors": [{
"code": 32,
"message": "Could not authenticate you."
}]
}
If i take a look with a web debugger i can verify that the authentication header got all the right keys but somehow the request fails while using httpx
. Does anyone have any suggestions on how to resolve this issue or how to debug this properly? Thanks in advance :)