aahoughton
(Andrew Houghton)
Juillet 24, 2020, 4:20
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 « J'aime »
simon
Juillet 24, 2020, 5:21
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 « J'aime »
aahoughton
(Andrew Houghton)
Juillet 24, 2020, 5:25
3
They should match, thank you – that was the call I was missing. Verifying.
jezra
(jezra)
Avril 26, 2021, 7:35
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)
Avril 27, 2021, 2:20
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 « J'aime »
sarahann
(Sarah)
Juillet 27, 2021, 2:14
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 « J'aime »
blake
(Blake Erickson)
Juillet 28, 2021, 1:03
7
It might not have been added to the api docs yet, I’ll make sure it gets documented soon.
3 « J'aime »
blake
(Blake Erickson)
Juillet 29, 2021, 11:53
8
@sarahann the /anonymize
route has been added to the api docs.
3 « J'aime »
Phew! Scared me for a sec
Thanks for the speedy turnaround on this!
1 « J'aime »