Failing to Overwrite Avatar Using SSO


(Rmwtoyon) #1

I have discourse set up to use a custom SSO server for login. I would like to use that login information to also update the user’s avatar automatically. In my ecosystem, the user’s username can be directly mapped to a URL (e.g., http://myserver.com/thumbnails/username.jpg).

I am having trouble getting the override to work. SSO authentication is working and I can override other things (like the user’s real name), but not the avatar. Here is the snippet (PHP) I am using:

$userparams = array(
  "nonce" => $nonce,
  "external_id" => $username,
  "username" => $username,
  "name" => $realname,
  "email" => $email,
  "avatar_force_update" => true,
  "avatar_url" => 'http://myserver.com/thumbnails/username.jpg');
$payload = base64_encode(http_build_query($userparams));
$sig = ...

Any idea what is going on? The URL is valid. Am I misinterpreting what discourse is expecting in terms of a URL?


(Kane York) #2

I think you want this:

"avatar_url" => 'http://myserver.com/thumbnails/$username.jpg');

I don’t think you have anyone named ‘username’, which would have made the problem more obvious.


(Rmwtoyon) #3

Thanks for the [quote=“riking, post:2, topic:22358”]
I think you want this…
[/quote]

Thanks but the validity of the URL is not the issue. I agree that you have found what would be a bug in my example code, but that is not the real code. I have verified that the URL being stored in the array points to an image by copying and pasting into my browser.

Assuming the URL in my example is valid, it sounds like you believe the avatar should be overwritten?


(Rmwtoyon) #4

This seems to work now. I’m not exactly sure what changed, but I am verifying that the avatars are overwritten.