401-ERROR inspite login

Hallo all. I’m trying to connect to OpenVidu server from my fastapi. Sending a get request to retrieve the sessions through this https:// YOUR_OPENVIDUSERVER_IP /openvidu/api/sessions. I’m getting a 200 response but also i’m getting a 401 error inside a dict {"timestamp":"2021-02-18T15:44:47.893+00:00","status":401,"error":"Unauthorized","message":"","path":"/openvidu/api/sessions"}
I’m using requests library. Here is my code

@app.get(“/redirect”)
async def read_openvidu():
url = ‘https://20.1.70.10/openvidu/api/sessions
payload_to_encode = “user:pass”
payload_to_encode_bytes = payload_to_encode.encode(‘ascii’)
base64_payload_to_encode_bytes = base64.b64encode(payload_to_encode_bytes).decode(“UTF-8”)

headers = {'Authorization': f'Basic {base64_payload_to_encode_bytes}'}

r = requests.get(url, headers=headers, verify=False)

return r.cookies

Also i’m not able to get past without verify=False. Because of SSL failure. What is the best workaround? Any help would be appreciated.

I got it working. Apparently I was sending wrong credentials to access OpenVidu node app instead off Openvidu server. With right details in the authorization header as mentioned in the docs you can access the contents. But the SSL cert fails when verfiy=False is removed. Don’t know why even after including CA bundle from certifi.
Edited:

@app.post(“/redirect”)
async def open_vidu():
url = ‘https:///openvidu/api/sessions’
payload_to_encode = “OPENVIDUAPP:MY_SECRET”
payload_to_encode_bytes = payload_to_encode.encode(‘ascii’)
base64_payload_to_encode_bytes = base64.b64encode(payload_to_encode_bytes).decode(“UTF-8”)

headers = {'Authorization': f'Basic {base64_payload_to_encode_bytes}'}

r = requests.post(url, headers=headers, verify=False)

return r.json()