问题
I am building Rails app using devise with omniauth-google-oauth2
.
Everthing work well but after i authenticate successfully with google,
image hash that i get is: https://lh4.googleusercontent.com/-zE4TdSazXvI/AAAAAAAAAAI/AAAAAAAAACA/jWRW9BtDAlU/s128-c/photo.jpg?sz=50
So, this make my image look so small, it is only 50px.
Although in Devise config i use:
config.omniauth :google_oauth2, "feaeas", "fefaascea",
{:image_aspect_ratio => "square",:image_size => 128}
How i can i get the large size from google authentication in Rails?
回答1:
I just had this same issue and unfortunately, I couldn't find a way to have Google Plus return a bigger image. I'm pretty sure it doesn't honor those size attributes anymore.
To fix the issue, I simply substituted the sz
attribute of the returned string and all is now well. Here's the Ruby I used:
url = auth.info.image.sub('?sz=50', '?sz=256')
回答2:
Depend on this an answer at How to config image size returned using omniauth-google-oauth2?
This is an issue of omniauth-google-oauth2
that was reported here. So just upgrade your gem to the latest version, this issue will be fixed!
回答3:
Settings below works for me:
config.omniauth :google_oauth2, google_client_id, google_client_secret, {
:prompt => "select_account",
:scope => "email, profile, plus.me, plus.login",
:image_aspect_ratio => "square",
:image_size => 150
}
gem "omniauth-google-oauth2", "~> 0.4.1"
来源:https://stackoverflow.com/questions/32496910/rails-devise-with-omniauth-google-oauth2-image-size-does-not-work