Closed tommy38hk closed 1 year ago
Hi there @tommy38hk 👋🏻 , thanks for filing the issue and sorry you're running into trouble here.
Are you able to share the CURL command structure you're using that is successfully making the API call?
The example configuration you provided looks like it's encoding the HTTP request body as application/json
, whereas the Auth0 documentation for POST /oauth/token is expecting application/x-www-form-urlencoded
in the request body.
Hi @austinvalle Here's the CURL command from Auth0, I have replaced the actual values of the sensitive fields.
curl --request POST \ --url https://my.auth0.com/oauth/token \ --header 'content-type: application/json' \ --data '{"client_id":"my-auth0-client-id","client_secret":"my-ayth0-client-secret","audience":"my-auth0-api-audience","grant_type":"client_credentials"}'
Quick test before I try and reproduce that issue, can you try updating your data block to use the Content-Type
header, currently it only has Accept
set:
data "http" "auth0_token" {
url = var.auth0_token_endpoint
request_body = local.auth0_json
method = "POST"
request_headers = {
content-type = "application/json"
accept = "application/json"
}
}
Yes, that fixed the issue. Thank you so much
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform CLI and Provider Versions
Terraform v1.4.6
Terraform Configuration
Expected Behavior
Be able to return the auth0 token
Actual Behavior
auth0_json_response = "{\"error\":\"access_denied\",\"error_description\":\"Unauthorized\"}"
Steps to Reproduce
terraform apply
How much impact is this issue causing?
Medium
Logs
No response
Additional Information
Proper token can be obtained using CURL command for the same credentials
Code of Conduct