07 Mar 2024 11:42 AM
Hi, i am using the below details to pull back a token (removed the OAuth details), but we get a badrequest 400 back with this body and no idea what the issue is.
Input:
Headers:
{ "Content-Type": "application/x-www-form-urlencoded" }
Body:
{ "grant_type": "client_credentials", "client_id": "*.*", "client_secret": "*", "scope": "account-idm-read account-idm-write", "resource": "*" }
Response:
Solved! Go to Solution.
03 Apr 2024 01:37 PM
Hi @Frazzle ,
you may have missed a the first bit in the resource filed.
try it like this:
curl --location --request POST 'https://sso.dynatrace.com/sso/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=dt0s02.*' \
--data-urlencode 'client_secret=dt0s02.*.*' \
--data-urlencode 'resource=urn:dtaccount:<your-account-id>' \
--data-urlencode 'scope=account-idm-read account-idm-write'
13 Aug 2024 09:50 AM
I have a similar issue:
curl --location --request POST 'https://sso.dynatrace.com/sso/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<client id>' \
--data-urlencode 'client_secret=<secret>' \
--data-urlencode 'resource=urn:dtaccount:<account-UUID>' \
--data-urlencode 'scope=app-engine:apps:install app-engine:apps:run'
{"errorCode":400,"message":"Bad Request","issueId":"K4DTL7WN6UVPGAM6","error":"invalid_request","error_description":""}%
10 Sep 2024 05:40 PM
To resolve the issue, generate a new OAuth Client.
In my case, the OAuth Client was dormant because it was created by a colleague who is no longer active in my Dynatrace account, resulting in the following response.
{ "errorCode": 400, "message": "Bad Request", "issueId": "XXXXXXXXXXX", "error": "invalid_request", "error_description": "" }
Here's the working cURL command/request body for your reference:
curl --location 'https://sso.dynatrace.com/sso/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<your-Client-ID>' \
--data-urlencode 'client_secret=<your-Client-secret>' \
--data-urlencode 'resource=urn:dtaccount:<your-account-UUID>' \
--data-urlencode 'scope=iam-policies-management account-idm-read account-idm-write'