如何配置使用omniauth-google-oauth2返回的图像大小? [英] How to config image size returned using omniauth-google-oauth2?

查看:136
本文介绍了如何配置使用omniauth-google-oauth2返回的图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的Rails应用程序中使用 devise 配置 omniauth-google-oauth2

  config.omniauth:google_oauth2,GOOGLE_APP_ID,GOOGLE_APP_SECRET,{
scope:'email,profile,plus.login',
provider_ignores_state:true,
提示:'select_account',
image_aspect_ratio:'square',
image_size:50,
skip_jwt:true
}

这项工作,但我尝试配置image_size更大:

  image_size:100,

  image_size:{width:100,height:100},

根据此文档,它不工作,它总是返回图像网址,如 https://lh4.googleusercontent.com/-zE4TdSazXvI/AAAAAAAAAAI/AAAAAAAAACA/jWRW9BtDAlU/s128-c/photo.jpg?sz=50



此问题是在使用omniauth-google-oauth2图像大小设置的Rails不起作用,但没有结果!



不要告诉我写这样的硬代码:

  url =https://lh4.googleusercontent.com/ -zE4TdSazXvI / AAAAAAAAAAI / AAAAAAAAACA / jWRW9BtDAlU / s128-c / photo.jpg?sz = 50
url = url.sub('?sz = 50','?sz = 100')

有另一种方法来实现吗?

解决方案

有一个 Github上的问题。修复在新的宝石中实现。对我来说,它有助于将 omniauth-google-oauth2 gem更新为版本> 0.2.6 。 / p>

尝试软件包更新omniauth-google-oauth2 或在 Gemfile中定义特定版本

  gemomniauth-google-oauth2,〜> 0.4.1


I try to config the omniauth-google-oauth2 with devise in my Rails app:

config.omniauth :google_oauth2, GOOGLE_APP_ID, GOOGLE_APP_SECRET, {
    scope: 'email, profile, plus.login',
    provider_ignores_state: true,
    prompt: 'select_account',
    image_aspect_ratio: 'square',
    image_size: 50,
    skip_jwt: true
}

This work but I try to config the image_size to be larger:

image_size: 100,

or

image_size: {width: 100, height: 100}, 

Based on this documentation, and it doesn't work, it always returns the image url like https://lh4.googleusercontent.com/-zE4TdSazXvI/AAAAAAAAAAI/AAAAAAAAACA/jWRW9BtDAlU/s128-c/photo.jpg?sz=50

This issue was raised at Rails devise with omniauth-google-oauth2 image size does not work as well, but no result on that!

Don't tell me to write this kind of hard code:

url = "https://lh4.googleusercontent.com/-zE4TdSazXvI/AAAAAAAAAAI/AAAAAAAAACA/jWRW9BtDAlU/s128-c/photo.jpg?sz=50"
url = url.sub('?sz=50', '?sz=100')

Is there another way to achieve this?

解决方案

There was an issue on Github about this. The fix is implemented in the new gems. For me it helped to simply update the omniauth-google-oauth2 gem to a version >0.2.6.

Try bundle update omniauth-google-oauth2 or define a specific version in your Gemfile:

gem "omniauth-google-oauth2", "~> 0.4.1"

这篇关于如何配置使用omniauth-google-oauth2返回的图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆