使用omniauth的Google open_id连接失败 [英] Connection failed for google open_id using omniauth

查看:69
本文介绍了使用omniauth的Google open_id连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的应用程序添加open-id功能,我正在使用omniauth和omniauth-openid gem.

I am trying to add open-id functionality to my app, I am using omniauth and omniauth-openid gems for same.

我已经完成了安装步骤,将其添加到作为中间件的初始化程序中,

I have done the installation steps added it to initializer as middleware,

require 'omniauth-openid'
require 'openid/store/filesystem'

Rails.application.config.middleware.use OmniAuth::Builder do 
  provider :open_id, :store => OpenID::Store::Filesystem.new('/tmp')
end

以及处理回调的路由

match '/auth/:provider/callback' => 'callback#myauthentication'

当我尝试点击此网址时,连接到 google provider

when I try to hit this url, to connect to google provider

http://[mydomain]/auth/open_id?openid_url=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid

我每次都会收到连接失败错误

I get connection failed error everytime

对于Yahoo http://[mydomain]/auth/open_id?openid_url=http%3A%2F%2Fme.yahoo.com%2F

For Yahoo http://[mydomain]/auth/open_id?openid_url=http%3A%2F%2Fme.yahoo.com%2F

如果我使用yahoo open id进行尝试,即使在正确身份验证之后,我也会遇到invalid_credentials错误 更新1: 我正在使用apache网络服务器和瘦/webrick应用服务器.我验证了,如果我不在apache Web服务器后面,并直接以localhost:3000的身份运行,则可以正常运行.为什么omniauth的行为会有所不同

Furthur if I try with yahoo open id , even after authenticating correctly I get invalid_credentials error Update 1: I am using apache web server, and thin/webrick app server. I verified that if I am not behind a apache web server and run directly as localhost:3000 it works fine. Why does omniauth behave differently

推荐答案

尝试一下这个宝石 https://github.com/zquestz/omniauth-google-oauth2 ,我的效果很好.

Try this gem https://github.com/zquestz/omniauth-google-oauth2, I've had good results with it.

这篇关于使用omniauth的Google open_id连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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