Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support for the HTTP Digest authentication on the requests and/or the aiohttp #869

Open
beyonlo opened this issue May 30, 2024 · 3 comments

Comments

@beyonlo
Copy link

beyonlo commented May 30, 2024

Hi all!

I need to communicate with some products that have an API that support only HTTP Digest authentication, I mean, they do not support HTTP Basic authentication and it is not possible to disable the authentication.

I see that MicroPython has two HTTP client libs that can be used for that purpose:

  1. requests (https://github.com/micropython/micropython-lib/tree/master/python-ecosys/requests) - It is sync, and support HTTP Basic authentication, but does not support HTTP Digest authentication
  2. aiohttp (https://github.com/micropython/micropython-lib/tree/master/python-ecosys/aiohttp/aiohttp) - It is async, and does not support HTTP Basic authentication and does not support HTTP Digest authentication as well.

I see there is this uwwwauth.py -> https://github.com/pfalcon/pycopy-lib/blob/master/uwwwauth/uwwwauth.py that is a support for HTTP Digest authentication for the pycopy (It seems to be like as old fork of MicroPython). Can that help to support HTTP Digest authentication on the requests and/or aiohttp http clients?

Is it a simple or difficult task to support HTTP Digest authentication on the MicroPython requests/aiohttp? If I were to choose just one that http client libs to be supported by the HTTP Digest authentication, I would like to be the aiohttp because it is async (asyncio), so I do not need to use threads to have a non blocking code. But if is supported just on the requests lib, is very good as well.

Thank you in advance!

@massimosala
Copy link

Hi @beyonlo

I think this request (pun intended) doesn't gain much attention because

@beyonlo
Copy link
Author

beyonlo commented Jun 19, 2024

Hello @massimosala

I think this request (pun intended) doesn't gain much attention because

So, the digest auth supported on cpython requests (code below) and aiohttp implements all that "gazillion" flavours?

import requests
from requests.auth import HTTPDigestAuth

url='https://example.com/cgi/metadata.cgi?template=html'
r = requests.get(url, auth=HTTPDigestAuth('myUsername', 'myPassword'), verify=False,  stream=True)        
print(r.headers) 
print(r.status_code)
  • nowadays most of web sites use OAuth

Understood. But many devices support only Digest Auth in the API. I already running it using cpython requests - works ok - but I need to use micropython.

@jonnor
Copy link

jonnor commented Aug 25, 2024

The code for HTTPDigestAuth in requests for CPython can be found here:
https://github.com/psf/requests/blob/a3ce6f007597f14029e6b6f54676c34196aa050e/src/requests/auth.py#L107

If that does what you need, then I recommend copying that code and porting it to MicroPython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants