How to make oauth2 and api call work in python?

Hi!
I’m trying to get the users list on my workspace with that api link using python.

But I’m probably doing something wrong. I’m trying to follow this tutorial. Can someone tell me what is wrong and how I can make it to work, please?

Here is the code i’m trying to run:

import requests
import json

BASE_URL = 'https://api.bitbucket.org/2.0/'
ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token'
AUTHORIZE_URL = 'https://bitbucket.org/site/oauth2/authorize'

# requesting an token:
data = { 'grant_type': 'client_credentials'}
response = requests.post(ACCESS_TOKEN_URL, data=data, auth=CONSUMER_KEY,CONSUMER_SECRET))
payload = json.loads(response.text)

#Using token to make the request
access_token = payload['access_token']
header = {
  'Authorization': f'Bearer {access_token}'
}

workspace = 'myworkspace'
endpoint = f'https://api.bitbucket.org/2.0/workspaces/{workspace}/members'

response = requests.get(endpoint, data=header)

print(response)
<Response [401]>