I have a community Rails site. I’m using SSO so that community members don’t have to separately log into Discourse and I’m using the Discourse API in order to facilitate exchange of information between the two servers. Now I’d like to unify user avatars, i.e. use the same avatar on the forum as on my main site. How do I do that?
I tried what I usually do for API requests, namely a Faraday POST request to https://discuss.diem25.org/uploads.json with API key and API-Username in the header and the following body:
This request results in an Internal Server Error. I’m also not opposed to re-uploading the file as a last resort, but that seems to be difficult to impossible at first glance, using Faraday.
Why not try the
sso overrides avatar site setting and pass the avatar URL with the SSO system? It may be better to handle this with SSO rather than making uploads manually with the API.
Thanks, that’s a good idea, it just poses the integration problem the other way round, because right now some users have an avatar on Discourse and don’t have an avatar on my site. So my choices are, it seems, to upload all Discourse avatars to my site and then set “sso overrides avatar”, or to upload all of my avatars to Discourse.
I think that is because you can’t just specify a url for a file in faraday, it has to be read in as a file first, or something like that.
However, you can use the discourse_api gem to update an avatar by specifying a url: