I am using the urequests lib from https://github.com/micropython/micropyt ... equests.py
I have tried out many different approaches (sorry, I can't remember them all).
Any snippet which shows how to achieve a proper GET and POST (with payload) requests while utilizing basic auth?
Thank you very much!
HTTP Requests with basic auth
Re: HTTP Requests with basic auth
I was now able to actually get some response:
import urequests
import json
headers = {'Authorization': 'Basic dGVzdDp0ZXN0'} # test:test
r = urequests.get("http://httpbin.org/basic-auth/test/test", headers=headers)
print(r.json())
This gives me the correct response:
{'authenticated': True, 'user': 'test'}
But if I now try to do exactly the same request to a httpS-host (httpS://httpbin.org/basic-auth/test/test), it raises the following error:
ssl_handshake_status: -80
Traceback (most recent call last):
File "<stdin>", line 67, in <module>
File "<stdin>", line 57, in get_data
File "urequests.py", line 101, in get
File "urequests.py", line 56, in request
OSError: [Errno 5] EIO
I think the error lies in the SSL handshake, but I do not know what to do.
Any advice, hints?
import urequests
import json
headers = {'Authorization': 'Basic dGVzdDp0ZXN0'} # test:test
r = urequests.get("http://httpbin.org/basic-auth/test/test", headers=headers)
print(r.json())
This gives me the correct response:
{'authenticated': True, 'user': 'test'}
But if I now try to do exactly the same request to a httpS-host (httpS://httpbin.org/basic-auth/test/test), it raises the following error:
ssl_handshake_status: -80
Traceback (most recent call last):
File "<stdin>", line 67, in <module>
File "<stdin>", line 57, in get_data
File "urequests.py", line 101, in get
File "urequests.py", line 56, in request
OSError: [Errno 5] EIO
I think the error lies in the SSL handshake, but I do not know what to do.
Any advice, hints?
Re: HTTP Requests with basic auth
Did you solve this problem?
I am stuck on the same fault, but don't know how to solve it..
I am stuck on the same fault, but don't know how to solve it..
Re: HTTP Requests with basic auth
I have the same issue on the ESP and unix.
Could this be an axtls issue?
Could this be an axtls issue?
-
- Posts: 1
- Joined: Wed Jul 12, 2017 7:30 pm
Re: HTTP Requests with basic auth
When I see "ssl_handshake_status: -80", it's because I didn't pass server_hostname to ussl.wrap_socket. See urequests/urequests.py from micropython-lib for an example.
The server_hostname parameter is for TLS's Server Name Indication (SNI), support for which was recently added to MicroPython via upstream changes to axTLS (https://github.com/micropython/micropython/issues/3140).
The server_hostname parameter is for TLS's Server Name Indication (SNI), support for which was recently added to MicroPython via upstream changes to axTLS (https://github.com/micropython/micropython/issues/3140).