klen / aioauth-client

OAuth client for aiohttp
MIT License
141 stars 43 forks source link

Percent encoding #118

Open emican86 opened 5 years ago

emican86 commented 5 years ago

Looking for suggestions on how to adjust percent encoding of oauth parameters. I'm in the process of creating a new client and requests work as long as '/' is not present in some oauth parameters. Has anyone else experienced a situation like this?

I tried overwriting Client._request to manually encoding parameters which are passed into aiohttp.ClientSession next line. It will work as long as '/' character is not present.

kwargs : {'params': {'oauth_consumer_key': 'aaa', 'oauth_nonce': '4a0ff66a0ac3674e6fd2b3b236890fb05dbe8304', 'oauth_signature_method': 'HMAC-SHA1', 'oauth_timestamp': '1551030612', 'oauth_version': '1.0', 'oauth_callback': 'oob', 'oauth_token': 'qbG4My9Lpz5mc5M1afhflTrG0NwOXN%2FH8bDFig4OoEU%3D',

Result: Get request fails with status 401. session.request(method, url, **kwargs) partly decoded the oauth token ? I thought aiohttp.ClientSession does not attempt percent encoding?

OAuth: oauth1 - DEBUG - response url: https://127.0.0.1?oauth_consumer_key=aaa&oauth_nonce=4a0ff66a0ac3674e6fd2b3b236890fb05dbe8304&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1551030612&oauth_version=1.0&oauth_callback=oob&oauth_token=qbG4My9Lpz5mc5M1afhflTrG0NwOXN/H8bDFig4OoEU%3D&oauth_signature=PA2VSz5drOUBWLbfLXiuPE9bB20%3D

https://tools.ietf.org/html/rfc5849#section-3.6 https://tools.ietf.org/html/rfc3986

jlricon commented 4 years ago

Adding client.escape = True may solve it