zquestz / omniauth-google-oauth2

Oauth2 strategy for Google
1.45k stars 413 forks source link

Picture URL in `raw_info` no longer contains `photo.jpg` #452

Open curtis opened 6 months ago

curtis commented 6 months ago

For a recent request, I was unable to get the image options to work (image_aspect_ratio and image_size). It looks like the raw_info now comes back with picture in a different format than previously expected. Here's a sample:

{
  "sub" => "12345",
  "name" => "John Smith",
  "given_name" => "John",
  "family_name" => "Smith",
  "picture" => "https://lh3.googleusercontent.com/a/ACg8ocJEHrk9eatVm3GZ5WkzLNAeKGVfhjJrIg4zjUALnGwSkLQ=s96-c",
  "email" => "john@smith.com",
  "email_verified" => true,
  "locale" => "en"
}

These lines in the google strategy explicitly look for photo.jpg in the URL and then attempt to apply the image options, if present. Since it's no longer part of the URL, path_index will be nil and image options will always be skipped.

https://github.com/zquestz/omniauth-google-oauth2/blob/2f8cefd7ef9701e92b7ee227073fb5f85c847817/lib/omniauth/strategies/google_oauth2.rb#L178-L197

Please let me know if I'm mistaken, or doing something incorrect. Thanks!