aahoughton
(Andrew Houghton)
July 24, 2020, 4:20pm
1
'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.
Am I missing something obvious? Any suggestions?
Thanks,
Andrew
4 Likes
simon
July 24, 2020, 5:21pm
2
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:
curl -X GET "http://localhost:3000/admin/users/list/all.json?email=bob@example.com" \
-H "Api-Key: $api_key" \
-H "Api-Username: system"
5 Likes
aahoughton
(Andrew Houghton)
July 24, 2020, 5:25pm
3
They should match, thank you – that was the call I was missing. Verifying.
jezra
(jezra)
April 26, 2021, 7:35pm
4
I am also interested in using an api call to anonymize a user. What is the API endpoint you are using to anonymize a user?
weallwegot
(juicecounty.prodigy)
April 27, 2021, 2:20am
5
The API endpoint for anonymizing:
HTTP Method: PUT
Endpoint: https://example-community.dev/admin/users/{id}/anonymize
Hi folks, I’m trying to hit the endpoint to anonymize a user in Discourse; I’ve got single sign-on between WordPress and Discourse set up, and when the user deletes their account on WordPress I want to anonymize them in Discourse. The endpoint is
/admin/users/{id}/anonymize:
put:
description: |
Anonymize a user
tags:
- Admin
parameters:
- name: id
in: path
required: true
type: integer
responses:
'200':
description: succesfully anonymized user
…
you can use the call shown above to get the {id}
value if you already know the email of the user you want to anonymize
7 Likes
sarahann
(Sarah)
July 27, 2021, 2:14am
6
Was the /anonymize
endpoint removed form the API docs?
I was looking here:
https://docs.discourse.org/#tag/Admin/paths/~1admin~1users~1{id}.json/get
Under users
as well as admin
.
2 Likes
blake
(Blake Erickson)
July 28, 2021, 1:03am
7
It might not have been added to the api docs yet, I’ll make sure it gets documented soon.
3 Likes
blake
(Blake Erickson)
July 29, 2021, 11:53pm
8
@sarahann the /anonymize
route has been added to the api docs.
3 Likes
sarahann
(Sarah)
August 19, 2021, 9:17pm
9
Phew! Scared me for a sec
Thanks for the speedy turnaround on this!
1 Like