mrparkers / terraform-provider-keycloak

Terraform provider for Keycloak
https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
MIT License
634 stars 313 forks source link

failed to perform initial login to Keycloak: invalid character '<' #779

Open geoff-carr-bzy opened 1 year ago

geoff-carr-bzy commented 1 year ago

Getting the following error when using version of the provider greater than 3.10.0, in this case v4.1.0: -

│ Error: error initializing keycloak provider
│
│   with provider["registry.terraform.io/mrparkers/keycloak"],
│   on main.tf line 17, in provider "keycloak":
│   17: provider "keycloak" {
│
│ failed to perform initial login to Keycloak: invalid character '<' looking for beginning of value

Reverting to 3.10.0 resolves the issue

mrparkers commented 1 year ago

This is most likely due to one of the breaking changes in v4.0.0 as described here: https://github.com/mrparkers/terraform-provider-keycloak/blob/master/CHANGELOG.md#v400-october-10-2022

  • updated the default value of the base_path provider attribute, it is now an empty string (#733)
    • this change was made due to the Quarkus distribution of Keycloak removing the /auth context from API urls. if you are currently using the Quarkus version of Keycloak, you no longer need to specify the base_path provider attribute as an empty string. if you are currently using the legacy version of Keycloak, you will need to add the base_path provider attribute and set it to /auth.

If updating your base_path provider attribute doesn't help, please try again with the TF_LOG=DEBUG environment variable set, and post the logs here (redacting all sensitive information).

flythebluesky commented 1 year ago

Also, I have seen this happen when the admin API endpoint is not accessible by the Terraform client, such as when the endpoint is protected from public access at a firewall; the "<" being returned is likely opening character of an html error page.