I am using requests
to call to Aruba's NBAPI for mobility master. Their documentation is scarce with Python examples. The API requires an initial auth to get a UID which needs to be referenced in each GET request. I cannot get the login to work within Python.
I'm using a GET request which may be part of the issue but it's my understanding of the curl
example provided by Aruba the default GET
method is being used. Please note I'm also not verifying the SSL cert as my end goal is zero touch provisioning.
Here is the curl command they offer to auth
curl --insecure -c "aruba-cookie-jar" -d "username=username&password=password" https://<url-here>:4343/v1/api/login
command output:
{"_global_result": {"status":"0", "status_str": "You've logged in successfully.", "UIDARUBA":"<key output here>"}}
I tried to convert this into python using 'requests' as shown below
import requests
session = requests.Session()
session.verify = False
r = session.get('https://<url-here>:4343/v1/api/login', auth=('username', 'password'))
I get the below when checking response (ipython)
In [6]: r.status_code
Out[6]: 401
In [7]: print(r.text)
{"_global_result": {"status":"1", "status_str": "Unauthorized request, authentication failed"}}
What am I doing wrong with this request? When using the POST method in Python results in the same output. I am thinking the auth
method being used in my Python example is not correct.