I want to make a script to create a new database and a new user with a specific user role

Hey @Guy_Buys - welcome to the community forums!

By passing your public and private key in a tuple, you’re asking Requests to perform Basic authentication, which is the default, whereas the Atlas API requires Digest authentication.

It’s simple enough to convert, you just need to wrap the two values with an HTTPDigestAuth instance: Authentication — Requests 2.32.3 documentation

Hope this helps!

Mark