This discussion revolves around the ability to anonymize or delete a user account using the API in a hosted Discourse instance with OAuth. aahoughton initially asked for a solution, as they couldn’t find a straightforward way to do this without knowing the Discourse account ID.
simon suggested retrieving the account ID by making an authenticated API request to /admin/users/list/all.json?email=<users_email_address>.
aahoughton found this helpful and was verifying the solution. Meanwhile, jezra asked about the API endpoint for anonymizing a user.
weallwegot provided the endpoint for anonymizing a user: https://example-community.dev/admin/users/{id}/anonymize (using a PUT request), and mentioned that the {id} value can be retrieved using the previously suggested API call.
sarahann noted that the /anonymize endpoint was not in the API docs, but blake assured that it would be documented soon. As of blake’s second post, the /anonymize route has been added to the API docs, which was confirmed by sarahann.
'lo. We’re using hosted discourse with OAuth. We suddenly realized that when we process deletions, we’re neglecting to delete from our discourse instance.
I’d like to be able to anonymize an account, OR delete an account programmatically using the API – but I don’t see an easy way to do that, given that I don’t know what the discourse account ID is.
Do you know if email addresses match between your OAuth identity provider and Discourse? If they do, you could get the Discourse user based on their email address by making an authenticated API request to /admin/users/list/all.json?email=<users_email_address>. For example: