Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
curtis opened this issue Feb 23, 2024 · 0 comments
Open

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

curtis opened this issue Feb 23, 2024 · 0 comments

Comments

@curtis
Copy link

curtis commented Feb 23, 2024

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.

def image_url
return nil unless raw_info['picture']
u = URI.parse(raw_info['picture'].gsub('https:https', 'https'))
path_index = u.path.to_s.index('/photo.jpg')
if path_index && image_size_opts_passed?
u.path.insert(path_index, image_params)
u.path = u.path.gsub('//', '/')
# Check if the image is already sized!
split_path = u.path.split('/')
u.path = u.path.sub("/#{split_path[-3]}", '') if split_path[-3] =~ IMAGE_SIZE_REGEXP
end
u.query = strip_unnecessary_query_parameters(u.query)
u.to_s
end

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

@curtis curtis changed the title Picture URL in raw_info no longer contains photo.jpg Picture URL in raw_info no longer contains photo.jpg Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant