How do I change a Python/request based script to Oauth2

I have a script that uses Python/requests to upload changes using the OSM API.
With the introduction of Oauth2, this doesn’t work anymore.
Are there any general guidelines on how to modify the script so that it works again, especially how I need to change the requests.post(...) call.
I have already a client id, client secret and an authentication code.

There’s a python example at GitHub - Zverik/cli-oauth2: Helper library for OAuth2 in command-line tools that will probably give you some pointers.