You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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 amanagement.User
withEmail
orPhoneNumber
set tonil
will marshal the struct to{}
, which will not delete the phone/email.Describe the ideal solution
Some suggestions:
management.User
could be changed/extended to allow explicitnull
in theUser.Update
-callUser.Update
could take an option (e.g.option.DeletePhoneNumber()
,option.DeleteEmail()
) that would set the correct payload.User.DeletePhone
andUser.DeleteEmail
(andUser.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: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
The text was updated successfully, but these errors were encountered: