使用 google oauth 2 策略范围失败的 OmniAuth
我正在努力使用 OmniAuth 和 google-oauth-2 策略从 Google 获取日历数据。
如果我没有在范围字段中添加任何内容,它就可以正常工作,并且我会获得默认信息,而无需验证/失败消息,并且我可以正常使用该应用程序。
然而,当我添加范围时,如下例所示,我收到“auth/failure?message=invalid_credentials”。
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
有什么我遗漏的或者我应该改变的吗?
I'm working on getting calendar data from google using OmniAuth and the google-oauth-2 strategy.
If I put nothing into the scope field it works fine and I get the default info without the auth/failure message and I can use the app normally.
However the moment I add a scope, as in the example below, I get an "auth/failure?message=invalid_credentials".
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
Is there something I'm missing or something I should change?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
google-oauth-2 策略作者发来的一封快速电子邮件指出了以下内容:
如果您不包含配置文件范围,则无法进行身份验证。
通过将
userinfo.email
和userinfo.profile
(以及日历范围)添加到逗号分隔的:scope
列表中,我能够修复问题。例子:
A quick e-mail from the google-oauth-2 strategy author pointed out the following:
If you don't include the profile scopes, it fails to authenticate.
By adding
userinfo.email
anduserinfo.profile
(along with the calendar scope) to the comma separated:scope
list I was able to fix the problem.Example: