I registered one Azure AD application and added DevOps API permission as below:

You need to use Delegated flow like authorization code flow, username password flow etc… with scope as 499b84ac-1321-427f-aa17-267ca6975798/.default
to generate bearer token for Azure DevOps.
Authorization code flow:
Initially, I ran below authorization request in browser and got code
value in address bar successfully like below:
https://login.microsoftonline.com/Tenant_Id/oauth2/v2.0/authorize
?client_id=Client_ID
&response_type=code
&redirect_uri=https://jwt.ms
&response_mode=query
&scope= 499b84ac-1321-427f-aa17-267ca6975798/.default
&state=12345

I ran below python code to generate bearer token for Azure DevOps like this:
import urllib3
urllib3.disable_warnings()
uri = "https://login.microsoftonline.com/tenantID/oauth2/v2.0/token"
payload= {
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'login.microsoftonline.com',
'client_id': 'appID',
'scope': '499b84ac-1321-427f-aa17-267ca6975798/.default',
'client_secret': 'enter_secret',
'grant_type': 'authorization_code',
'code': 'paste_code_value_from_above_step',
'redirect_uri':'https://jwt.ms'
}
http = urllib3.PoolManager()
response = http.request('POST', uri, payload)
print(response.data)
my_dict = eval(response.data)
token = my_dict['access_token']
print(token)
Response:

To confirm that, you can decode the token in jwt.ms and check aud
and scp
claims like below:

To generate bearer token with username password flow, you can make use of below python code:
import urllib3
urllib3.disable_warnings()
uri = "https://login.microsoftonline.com/tenantID/oauth2/v2.0/token"
payload= {
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'login.microsoftonline.com',
'client_id': 'appID',
'scope': '499b84ac-1321-427f-aa17-267ca6975798/.default',
'client_secret': 'secret',
'grant_type': 'password',
'username':'nmo@xxxxxxxxxx.onmicrosoft.com',
'password':'xxxxxxxxxx'
}
http = urllib3.PoolManager()
response = http.request('POST', uri, payload)
print(response.data)
my_dict = eval(response.data)
token = my_dict['access_token']
print(token)
Response:
