Reset avatar in sync SSO

I am looking to reset the avatar while using the sync_sso (back to using the letter_avatar_proxy).
Currently I am passing avatar_force_update=true and no value for avatar_url . Should I be passing an explicit (null?) value for avatar_url instead? Thanks in advance

From looking at the Discourse SSO code, I don’t think it is going to be possible to reset a user’s avatar to a letter avatar by calling sync_sso. What the code does is try to download the avatar from the URL that is passed with the avatar_url parameter. If that parameter is omitted, or set to null, or an empty string, no change will be made to the user’s avatar.

3 Likes

How might I request that the API to do such a thing? I attempted to implement a workaround but it’s not quite working out.

A good approach to figure out what API call to make to perform an action is to perform the action through the Discourse user interface while watching your web inspector’s network tab to find details about the request that is being made. See How to reverse engineer the Discourse API for details about this approach.

User avatars can be updated to the system avatar by making an API PUT request to

http://forum.example.com/u/<discourse_username>/preferences/avatar/pick

Set type=system in the request’s form data. You’ll need to substitute your forum’s URL and the Discourse username that you want to update into the URL.

Here’s an example curl request from my local site. I’ve set $api_key to my All Users API Key:

curl -X PUT "http://localhost:3000/u/scossar/preferences/avatar/pick" \
-H "Api-Key: $api_key" \
-H "Api-Username: system" \
-H "Content-Type: multipart/form-data;" \
-F "type=system"

One thing to note is that this request will fail if you have enabled the sso overrides avatar site setting.

1 Like

Oddly enough that’s the workaround I tried, but I was seeing inconsistent results. I will bang on it a bit more and report back.

1 Like