Skip to content

Can't round-trip fields from management.UserIdentitySchema to management.Identity #806

Description

@haines

Checklist

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

Description

management.UserIdentitySchema now has a UserID field of type *management.UserID, but management.Identity's UserID is of type string.

That makes it awkward to get a user identity's ID from one API call and pass it into another.

Also, the Provider fields have different types, even though they appear to be equivalent enums.

Expectation

User identities have consistently-typed fields so that you can round-trip them easily.

Reproduction

package users

import (
	"context"
	"fmt"

	"github.com/auth0/go-auth0/v2/management"
	"github.com/auth0/go-auth0/v2/management/client"
)

func resendVerificationEmail(ctx context.Context, id string) error {
	auth0, err := client.New("...")
	if err != nil {
		return err
	}

	user, err := auth0.Users.Get(ctx, id, &management.GetUserRequestParameters{
		Fields:        new("identities"),
		IncludeFields: new(true),
	})
	if err != nil {
		return err
	}

	if len(user.Identities) != 1 {
		return fmt.Errorf("user %w has %d identities", len(user.Identities))
	}

	identity := user.Identities[0]

	_, err = auth0.Jobs.VerificationEmail.Create(ctx, &management.CreateVerificationEmailRequestContent{
		ClientID: new("..."),
		UserID:   id,
		Identity: &management.Identity{
			// cannot use identity.GetProvider() (value of string type management.UserIdentityProviderEnum) as management.IdentityProviderEnum value in struct literal
			Provider: identity.GetProvider(),

			// cannot use identity.GetUserID() (value of struct type management.UserID) as string value in struct literal
			UserID: identity.GetUserID(),
		},
	})
	return err
}

Auth0 Go SDK version

v2.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions