adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 36 forks source link

HTTPBasicAuth Feature #180

Open FoamyGuy opened 3 months ago

FoamyGuy commented 3 months ago

In CPython requests it looks like there is HTTPBasicAuth which handles encoding credentials into the appropriate format. https://requests.readthedocs.io/en/latest/user/authentication/ we could add that class in the adafruit_requests library and then have matching APIs between circuitpython and CPython more closely.

Once implemented this could be used to simplify a few of the examples that make use of basic auth.

This was originally discussed in #167

justmobilize commented 3 months ago

@FoamyGuy I think that makes sense. Happy to tackle this if you want

FoamyGuy commented 3 months ago

@justmobilize sounds good, you can if you'd like. Thank you!

justmobilize commented 2 months ago

@FoamyGuy and @dhalbert I've got this working locally, but have a question.

In CPython it's requests.auth.HTTPBasicAuth. Do we want to mimic that and update requests to have multiple files (and include the main one in __init__ so we don't break things)? Or do we want to just do requests.HTTPBasicAuth?

It's not like it's very big, but if we wanted to add more features, allowing things to be broken up makes sense...

FoamyGuy commented 2 months ago

Breaking it up from a single file to a directory with multiple files is okay IMO. So long as if it's an incompatible change we bump the major version and update examples / learn guide code that need it.

It does also feel like a natural time to do it if we want to add auth.HTTPBasicAuth and keep it's importing and usage compatible with CPython.

justmobilize commented 2 months ago

@FoamyGuy do you know if circup handles this? changing from a single file to a directory?

justmobilize commented 2 months ago

I tested and it doesn't. I hacked it around esp32spi:

image

So it deleted the old version, but couldn't install the new one

justmobilize commented 2 months ago

@FoamyGuy and @dhalbert I'm thinking of first tackling updating circup to support this switch. Would you both agree?