0

In on of my view tests, I tried to make a simple get request that requires Basic Auth using a client:

staff_credentials = base64.b64encode(b'staff_user:staff_password').decode('utf-8')
response = client.get(url, headers={
            "Authorization": f"Basic {staff_credentials}"            
})
assert response.status_code == 200

But I keep getting a 401 response corresponding to an Unauthorized access. Is there any problem with my method?

Thanks.

vasco_t
  • 133
  • 1
  • 9
  • 2
    Does this answer your question? [Using Basic HTTP access authentication in Django testing framework](https://stackoverflow.com/questions/5495452/using-basic-http-access-authentication-in-django-testing-framework) – Davit Tovmasyan Dec 19 '19 at 10:13
  • @DavitTovmasyan It does, thank you. – vasco_t Dec 19 '19 at 16:29

0 Answers0