terraform-provider-auth0 icon indicating copy to clipboard operation
terraform-provider-auth0 copied to clipboard

auth0_connection : import state error for google-oauth2

Open arrase opened this issue 2 years ago • 2 comments

Checklist

  • [X] I have looked into the README and have not found a suitable solution or answer.
  • [X] I have looked into the documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have upgraded to the latest version of this provider and the issue still persists.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

Description

$ terraform import auth0_connection.google_oauth2 XXXXXXXXXXXXXXXXX
auth0_connection.google_oauth2: Importing from ID "XXXXXXXXXXXXXXXXX"...
auth0_connection.google_oauth2: Import prepared!
  Prepared auth0_connection for import
auth0_connection.google_oauth2: Refreshing state... [id=XXXXXXXXXXXXXXXXX]
╷
│ Error: decoding response payload failed: json: cannot unmarshal string into Go struct field ConnectionOptionsGoogleOAuth2.allowed_audiences of type []interface {}
│
│
╵

Expectation

Import the current state from google-oauth2 connection kind

Reproduction

  1. Configure a google-oauth2 connection with your own client_id and client_secret
  2. Try to import the state from terraform with:
terraform import auth0_connection.google_oauth2 XXXXXXXXXXXXXXXXX

Auth0 Terraform Provider version

0.37.0

Terraform version

1.2.6

arrase avatar Sep 08 '22 18:09 arrase

Related to https://github.com/auth0/go-auth0/issues/14

jmisur avatar Sep 16 '22 12:09 jmisur

Hey folks 👋🏻 , thanks for reporting this!

This is related to auth0/go-auth0#14 indeed. When the google oauth2 connection gets first created it will return the allowed_audiences as an empty string instead of an empty array.

Not ideal, but until we fix this on the go auth0 SDK side or even better the API itself, a workaround would be to fill up the field in question in the UI with some dummy value, save, clear, save again. This will make it such that the API will return the field as an array afterwards and not fail any more when importing.

sergiught avatar Sep 17 '22 12:09 sergiught

I'm running into this issue as of now after configuring non-dev Google API keys. This issue doesn't exist in our alpha tenant which still uses Auth0's default dev keys.

mswezey23 avatar Dec 05 '22 16:12 mswezey23

FYI: this also affects the new auth0_connection_client resource

│ Error: failed to unmarshal response payload: json: cannot unmarshal string into Go struct field ConnectionOptionsGoogleOAuth2.allowed_audiences of type []string
│ 
│   with auth0_connection_client.app["google"],
│   on auth.tf line 63, in resource "auth0_connection_client" "app":
│   63: resource "auth0_connection_client" "app" {

renan-abm avatar Dec 20 '22 17:12 renan-abm

Hi,

Same issue here and it is quite important on our side. Any way we can help to solve this issue ?

Jno21 avatar Dec 29 '22 15:12 Jno21

+1

mjpolak avatar Mar 08 '23 08:03 mjpolak

Hey folks 👋🏻

Apologies for the wait on this one, we were trying to push for a patch for this on the API side, but unfortunately that won't be possible so we're gonna have to work around this within the Go SDK that powers this provider (https://github.com/auth0/go-auth0). We're aiming at having this ready for the provider some time next week. I'll keep you updated in case of delays.

Thanks!

sergiught avatar Mar 08 '23 08:03 sergiught

@sergiught Thanks for feedback!

mjpolak avatar Mar 08 '23 08:03 mjpolak

Hey @sergiught any chance for release today?

mjpolak avatar Mar 17 '23 11:03 mjpolak

Hey folks, appreciate everyone's patience with this one.

The fix is available now in the latest release v0.45.0. Please give it a go and let us know if you have any issues with it. Thanks!

Docs: https://registry.terraform.io/providers/auth0/auth0/0.45.0/docs

sergiught avatar Mar 17 '23 13:03 sergiught

Thanks, it works!

mjpolak avatar Mar 17 '23 14:03 mjpolak