问题描述
我正在使用devise与 omniauth-google-oauth2
构建Rails应用程序。
一切正常工作,但在我用google成功验证之后,我得到的
图像哈希是: https://lh4.googleusercontent.com/-zE4TdSazXvI/AAAAAAAAAAI/AAAAAAAAACA/jWRW9BtDAlU /s128-c/photo.jpg?sz=50
所以,这使我的图像看起来很小,只有50px。
虽然在Devise配置我使用:
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}
我如何从Rails的Google身份验证中获得大尺寸?
How i can i get the large size from google authentication in Rails?
推荐答案
我刚刚遇到同样的问题,不幸的是,我找不到一种方法让Google Plus返回更大的形象。我很确定它不再符合这些大小的属性。
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.
为了解决这个问题,我只是将 sz
返回的字符串的属性现在都很好。这是我使用的Ruby:
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')
这篇关于使用omniauth-google-oauth2图像大小的Rails设计不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!