This article clarifies how to debug Terraform permission errors when using Terraform with the client credentials flow, even when all required OAuth 2.0 scopes are present.
An example error message:
Error: failed to create rule: the API returned an error: You do not have permission to perform the requested action
- Terraform using private key
- Okta Management API
- OAuth 2.0
- Service applications
This error occurs because managing certain resources requires an standard administrator role assigned to the service application. Custom roles do not have all the necessary permissions to manage all resources in Okta.
First, identify the role necessary to perform the action. To do this, enable Terraform trace and capture the Terraform logs.
Prepend the following to Terraform commands for debug output:
TF_LOG=trace TF_LOG_PATH="<FILENAME>" <your terraform command>
For example:
TF_LOG=trace TF_LOG_PATH="terraform.txt" terraform plan
TF_LOG=trace TF_LOG_PATH="terraform.txt" terraform apply
This should show request and response logs from Terraform.
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: {
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: "errorCode": "E0000006",
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: "errorSummary": "You do not have permission to perform the requested action",
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: "errorLink": "E0000006",
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: "errorId": "oaezpF5B5KoTxq-E2TUMNjE3g",
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: "errorCauses": []
2025-12-18T14:39:08.845+0530 [DEBUG] provider.terraform-provider-okta_v6.3.0: }
Once the detailed trace is generated, the response reveals the exact details of the failure.
Follow the steps mentioned in the article below to fix any permission-related errors. For example, assigning the Org admin role:
Receiving Error Code E0000006 when Calling Okta Management API Despite Having Correct Scopes
