Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for deleting phone-numbers or emails #520

Open
1 task done
bendiknesbo opened this issue Mar 5, 2025 · 0 comments
Open
1 task done

Add support for deleting phone-numbers or emails #520

bendiknesbo opened this issue Mar 5, 2025 · 0 comments
Labels

Comments

@bendiknesbo
Copy link

Checklist

Describe the problem you'd like to have solved

With the recent addition of Connection Attributes, we would like to make a call to Management API to delete a user's phone-number or email. We can do that by sending a PATCH call to the users-endpoint (https://auth0.com/docs/api/management/v2/users/patch-users-by-id), with the payload {"phone_number":null} or {"email":null}.

However, there is no way to achieve this when using the Auth0 Go SDK, by using the function User.Update, since passing in a management.User with Email or PhoneNumber set to nil will marshal the struct to {}, which will not delete the phone/email.

Describe the ideal solution

Some suggestions:

  • The management.User could be changed/extended to allow explicit null in the User.Update-call
  • User.Update could take an option (e.g. option.DeletePhoneNumber(), option.DeleteEmail()) that would set the correct payload.
  • A separate User.DeletePhone and User.DeleteEmail (and User.DeleteUsername also?) could be added, which would send the required payload.

Alternatives and current workarounds

A workaround is to use NewRequest and pass a payload that overrides the default Go marshalling, like:

type deletePhoneRequest struct{}
func (r deletePhoneRequest) MarshalJSON() ([]byte, error) {
	return []byte(`{"phone_number":null}`), nil
}

This requires us to manually handle the path to the PATCH-endpoint, and handling the status-code and closing of body, etc. manually.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant