I am thinking that your API is protected with JWTs and you are trying BasicAuth with username and password to access it, while what you need is a token. Basic Auth is for protected resources that require a sign-in while trying to visit the page.
Like this (from requests docs): https://httpbin.org/basic-auth/user/pass
What you would want to do is sent a request to your authentication endpoint with the username and password and get a token, and use that in your request.