Skip to content

Unmarshaling error in IdentityProviderApplicationUser.Profile field when calling ListIdentityProviderApplicationUsers #516

@moemoeq

Description

@moemoeq

Describe the bug?

The IdentityProviderApplicationUser struct in the Okta Go SDK v5 has an issue with the Profile field deserialization. When calling ListIdentityProviderApplicationUsers, the API returns JSON with a nested object in the profile field, but the SDK fails to unmarshal it with an error:

json: cannot unmarshal string into Go struct field _IdentityProviderApplicationUser.profile of type map[string]interface {}

I believe the IdentityProviderApplicationUser type should be map[string]interface{} instead map[string]map[string]interface{}

type IdentityProviderApplicationUser struct {
Created *string `json:"created,omitempty"`
ExternalId *string `json:"externalId,omitempty"`
Id *string `json:"id,omitempty"`
LastUpdated *string `json:"lastUpdated,omitempty"`
Profile map[string]map[string]interface{} `json:"profile,omitempty"`
Embedded map[string]map[string]interface{} `json:"_embedded,omitempty"`
Links *LinksSelf `json:"_links,omitempty"`
AdditionalProperties map[string]interface{}
}

What is expected to happen?

The SDK should correctly unmarshal the JSON response into the IdentityProviderApplicationUser struct, with the Profile field properly populated as a map[string]interface{} containing all the profile attributes from the JSON response.

What is the actual behavior?

The SDK throws a JSON unmarshaling error when processing the response:
json: cannot unmarshal string into Go struct field _IdentityProviderApplicationUser.profile of type map[string]interface{}

Reproduction Steps?

Use the Okta Go SDK v5.0.5
Create a client with proper authentication
Call the following code:

func ListIdpUsers(client *okta.APIClient, idpId string) {
    ctx := context.Background()
    users, resp, err := client.IdentityProviderAPI.ListIdentityProviderApplicationUsers(ctx, idpId).Execute()
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Printf("Response: %+v\n", resp)
}

Additional Information?

fix IdentityProviderApplicationUser struct like this with change related function and boom! works

type IdentityProviderApplicationUser struct {
	Created              *string                           `json:"created,omitempty"`
	ExternalId           *string                           `json:"externalId,omitempty"`
	Id                   *string                           `json:"id,omitempty"`
	LastUpdated          *string                           `json:"lastUpdated,omitempty"`
	Profile              map[string]interface{}            `json:"profile,omitempty"`
	Embedded             map[string]map[string]interface{} `json:"_embedded,omitempty"`
	Links                *LinksSelf                        `json:"_links,omitempty"`
	AdditionalProperties map[string]interface{}
}

Sample Response (censored)

{
    "id": "00uxxxxxxxxxxxxxxxx",
    "externalId": "[email protected]",
    "created": "2024-07-22T05:04:28.000Z",
    "lastUpdated": "2025-05-08T02:22:39.000Z",
    "profile": {
      "lastName": "Doe",
      "subjectConfirmationMethod": "urn:oasis:names:tc:SAML:2.0:cm:bearer",
      "jobtitle": "Team Member",
      "authnmethodsreferences": "http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password",
      "objectidentifier": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "identityprovider": "https://sts.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/",
      "subjectSpProvidedId": null,
      "authNContextClassRef": "urn:oasis:names:tc:SAML:2.0:ac:classes:Password",
      "subjectConfirmationAddress": null,
      "firstName": "(Dev_Team)",
      "subjectSpNameQualifier": null,
      "mobilePhone": "+xx xx-xxxx-xxxx",
      "subjectNameFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
      "subjectNameQualifier": null,
      "tenantid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "department": "DEV / R&D / Team",
      "subjectNameId": "[email protected]",
      "email": "[email protected]"
    },
    "_links": {
      "idp": {
        "href": "https://example.okta.com/api/v1/idps/0oaxxxxxxxxxx"
      },
      "self": {
        "href": "https://example.okta.com/api/v1/idps/0oaxxxxxxxxxx/users/00uxxxxxxxxxxxxxxxx",
        "hints": {
          "allow": [
            "GET",
            "DELETE"
          ]
        }
      },
      "user": {
        "href": "https://example.okta.com/api/v1/users/00uxxxxxxxxxxxxxxxx"
      }
    }
}

Golang Version

1.24.2

SDK Version

v5.0.5

OS version

Darwin MYMAC.local 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions