Error retrieving organization: unauthorized

Started getting this error authenticating with the TFE provider. I have a TFE_TOKEN set, I recreated a new token, and I have also tried to set the token parameter on the provider declaration in terraform. All methods throw the Error retrieving organization: unauthorized error. I’m not sure how to further troubleshoot but this was working about a week ago or so and now is not with nothing changed on our end.

In case it matters I am the only person in this account and I am the owner so I should have all permissions needed.

Anyone have thoughts?

Hello,

Can you please share the steps with an example config so I can attempt to recreate it along with versions you are using.

The same issue occurred.

data "tfe_organization" "organization" {
  name = var.tfc_organization
}

output

╷
│ Error: Error retrieving organization: unauthorized
│ 
│   with module.terraform_cloud_reference_engine.data.tfe_organization.organization,
│   on engine/tfc_auth.tf line 5, in data "tfe_organization" "organization":
│    5: data "tfe_organization" "organization" {
│ 
╵
Operation failed: failed running terraform plan (exit 1)

I tried executing “terraform login” to renew the token, but it not working.

The problem was solved. I found that the token in data.aws_secretsmanager_secret_version.tfe_token_secret was not updated.

data "aws_secretsmanager_secret_version" "tfe_token_secret" {
  secret_id = "terraform-cloud-credentials-for-bootstrap"
}

provider "tfe" {
  hostname = var.tfc_hostname
  token    = data.aws_secretsmanager_secret_version.tfe_token_secret.secret_string
}