I have a problem using the rest api for oauth authentication.
As described in your documentation I used POST in the request to the following endpoint:
https://sso.dynatrace.com/sso/oauth2/token
I executed the instructions providing all the parameters in the request body, but when I execute the request I get an http error code 400 (Bad Request). How can I solve the problem? The python code follows:
import requests
oauth_client = “my_oauthClient”
oauth_secret = “my_oauthSecret”
oauth_scope = "storage:events:read " \
"storage:buckets:read " \
"account-idm-write " \
"account-idm-read " \
"account-env-read " \
"account-env-write " \
"account-uac-read " \
"account-uac-write " \
"iam-policies-management " \
"iam:policies:write " \
"iam:policies:read " \
"iam:bindings:write " \
"iam:bindings:read " \
“iam:effective-permissions:read”
oauth_resource = “my_urn:dtaccount:xxxxxxxxxxxxxx”
sso_url = “https://sso.dynatrace.com/sso/oauth2/token”
my_data = {
‘grant_type’: ‘“client_credentials”’,
‘client_id’: oauth_client,
‘client_secret’: oauth_secret,
‘scope’: oauth_scope,
‘resource’: oauth_resource}
my_headers = {“Content-Type”: “application/x-www-form-urlencoded”}
response = requests.post(sso_url,params={},my_headers=headers,data=my_data)
token = response.json().get(“access_token”)