go-auth0 / auth0

ARCHIVED Go SDK for the Auth0 platform. This project is now being maintained at: https://github.com/auth0/go-auth0

Home Page:https://github.com/auth0/go-auth0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug when decoding Social Google Connection

juniocezar opened this issue · comments

The allowed audiences field for the Google OAuth2 Social connection has the []interface{} type.

AllowedAudiences []interface{} `json:"allowed_audiences,omitempty"`

The Social Google account usually comes enabled by default in Auth0, but if you disable it:

image

and run a ConnectionManager.List() to get the list of all connections, this Social Google connection is still being listed.

{
    "total":1,
    "start":0,
    "limit":50,
    "connections":[
       {
          "id":"con_jBya21zJU4o*****",
          "options":{
             "email":true,
             "gmail":false,
             "orkut":false,
             "scope":[
                "email",
                "profile"
             ],
             "sites":false,
             "tasks":false,
             "blogger":false,
             "profile":true,
             "youtube":false,
             "calendar":false,
             "contacts":false,
             "analytics":false,
             "client_id":"",
             "moderator":false,
             "coordinate":false,
             "picasa_web":false,
             "google_plus":false,
             "google_books":false,
             "google_drive":false,
             "spreadsheets":false,
             "client_secret":"",
             "document_list":false,
             "latitude_best":false,
             "latitude_city":false,
             "url_shortener":false,
             "webmaster_tools":false,
             "chrome_web_store":false,
             "allowed_audiences":"",
             "adsense_management":false,
             "google_drive_files":false,
             "coordinate_readonly":false,
             "google_cloud_storage":false,
             "content_api_for_shopping":false,
             "google_affiliate_network":false
          },
          "strategy":"google-oauth2",
          "name":"google-oauth2",
          "is_domain_connection":false,
          "realms":[
             "google-oauth2"
          ],
          "enabled_clients":[
 
          ]
       }
    ]
 }

The problem here is that the allowed_audiences option comes as an empty string, leading to an Unmarshall error.

json: cannot unmarshal string into Go struct field ConnectionOptionsGoogleOAuth2.allowed_audiences of type []interface {}

I may try to work on a fix for it when I get some spare time

Hi @juniocezar, I have been tracking this issue at the tf provider as well and I was under the impression this was fixed from Auth0.

alexkappa/terraform-provider-auth0#198

Perhaps some kind of regression? I'll ping them, otherwise we could write a custom unmarshaller for the connection type (I'd rather avoid this if possible).

This just came up for me, also. I turned on debug mode and checked out the JSON and see "allowed_audiences": "" in the JSON from Auth0. Lucky for me, this connection was accidentally turned on in our tenant and now I can go delete it and make my problem disappear.

Unfortunately for me, when you are using List on the ConnectionManager struct, the error is pretty generic:

json: cannot unmarshal string into Go struct field ConnectionList.connections of type []interface {}

It wasn't until I downloaded the JSON, broke the list into individual objects and tried to Unmarshal them each individually that I got to see the actual error referenced in the original issue above. Which I'm pretty sure is an annoyance of Go's JSON library, but just in case somebody else runs into this issue, that's how I dealt with it.

I just hit this, filling up "Allowed Mobile Client IDs" field in their UI with some dummy value, save, clear, save again fixed it for me.

Closed and cloned this issue to auth0/go-auth0#14.