我正在使用google-oauth-2策略和OmniAuth从谷歌获取日历数据。
如果我在范围字段中不放任何东西,它就能正常工作,并且我可以在没有auth/failure消息的情况下获得默认信息,并且我可以正常使用该应用程序。
但是,当我添加一个作用域时,如下面的示例所示,我会得到一个“auth/failure?message=failure_凭据”。
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV['TEST_KEY'], ENV['TEST_SECRET'], { :scope => 'https://www.google.com/calendar/feeds/' }
end有什么东西我错过了还是有什么我该换的?
发布于 2011-12-19 23:07:02
一封来自google 2战略作者的快速电子邮件指出:
如果不包括配置文件作用域,则无法进行身份验证。
通过将userinfo.email和userinfo.profile (以及日历范围)添加到逗号分隔的:scope列表中,我能够解决问题。
示例:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV['TEST_KEY'], ENV['TEST_SECRET'],
{ :scope => 'userinfo.email, userinfo.profile, https://www.googleapis.com/auth/calendar' }
end发布于 2011-12-28 17:17:06
有趣的是,这对我没有用。我能够使它工作,从作用域中删除逗号:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV['TEST_KEY'], ENV['TEST_SECRET'],
{ :scope => 'https://www.googleapis.com/auth/docs https://www.googleapis.com/auth/userinfo.profile' }
endhttps://stackoverflow.com/questions/8541088
复制相似问题