Hello @MuhammadUsman
There is no single answer, as there is always a ‘person’ involved, since authenticating to the REST API requires a user’s credentials. The only difference is that OAuth is meant for applications that will present that user, a real person, with an interface to approve the application, whereas Basic Auth is meant for scripts where that user’s credentials (a key and a token) are either embedded in the script or looked up from another source.
There really isn’t a problem with having a service account set aside for your Python scripts to use for Basic Auth sessions. Once you generate the key / token for that service account, use some sort of hashing / encrypting method to encode it and then store it in a text file that only the scripts can access. When the Python scripts run, they just un-hash the information from the file, then use the extracted key / token for the session.
I personally like the idea of disposable service accounts; they can be set to have a limited lifespan and you can always delete and re-generate their keys / tokens if you think those credentials have become too widely known by transient staff.