Tag: omn​​iauth

Rails3 omniauth google身份validation返回用户身份

我的Omniauth集成适用于本地开发,但谷歌在登台时失败。 require ‘omniauth/openid’ require ‘openid/store/memcache’ Rails.application.config.middleware.use OmniAuth::Builder do OmniAuth.config.full_host = “http://xx.xx.xxx/” # dedicated openid provider :open_id, OpenID::Store::Memcache.new(Dalli::Client.new), :name => ‘google’, :identifier => ‘https://www.google.com/accounts/o8/id’ end 我收到此错误消息: 开始GET“/ auth / failure?message = invalid_credentials”for 58.71.19.178 at 2011-12-01 02:22:20 +0000由ErrorsController处理#routing as HTML参数:{“message”=>“invalid_credentials”,“a “=>”auth / failure“}渲染公共/ 404.html(0.1ms)已完成404未在1ms内找到(视图:0.6ms | ActiveRecord:0.0ms) 我的OmniAuth.config.full_host中的ip in for也不一样可能导致问题?

如何从omniauth获取facebook的时区?

user.rb中的所有内容在注册时正确传递,时区除外。 我无法弄清楚为什么我在尝试登录时遇到此错误 : 2016-03-30T20:13:38.083469+00:00 app[web.1]: NoMethodError (undefined method `timezone=’ for #): 2016-03-30T20:13:38.083470+00:00 app[web.1]: app/models/user.rb:72:in `block in from_omniauth’ 2016-03-30T20:13:38.083471+00:00 app[web.1]: app/models/user.rb:66:in `tap’ 2016-03-30T20:13:38.083471+00:00 app[web.1]: app/models/user.rb:66:in `from_omniauth’ 2016-03-30T20:13:38.083472+00:00 app[web.1]: app/controllers/sessions_controller.rb:7:in `facebook’ user.rb def self.from_omniauth(auth) # Sets 60 day auth token oauth = Koala::Facebook::OAuth.new(“1540371223342976229929”, “ee917abf2e8f1c98274cd323fa1234ebb1346f4”) # Fake Numbers new_access_info = oauth.exchange_access_token_info auth.credentials.token new_access_token = new_access_info[“access_token”] new_access_expires_at = DateTime.now […]

如何在配置/初始化程序中使用YML值

我正在努力将facebook整合到我的应用中。 要做到这一点,我正在使用考拉,设计和omniauth。 对于考拉,我有 /config/facebook.yml development: app_id: 123123132123 secret_key: dasadsasd1231231 test: app_id: 313131313 secret_key: das132asdads12132 production: app_id: dasdsadsadsadsa secret_key: adsdsa12das123fds21 然后我也有了omniauth: /config/initalizers/omniauth.rb Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, 123123132123, ‘dasadsasd1231231’ end 这里的问题是我在两个位置都重复了相同的值。 我该如何干这个,以便app_id和secret_key只存在于一个地方,一个文件引用另一个?

puma生产服务器在后台:omniauth记录到stdout失败导致错误

我使用rails + puma作为我的生产服务器。 我使用httpd设置虚拟机并将请求转发给localhost:3000。 我用来启动我的puma服务器的命令是(已在app文件夹中) puma -e production -p 3000 & 当我仍然使用ssh登录服务器时,我的网络应用程序的一切都很好。 只有一些日志实际出现在屏幕上(我没注意它)。 但是,当我退出ssh会话时。 我不能使用omniauth(gem)。 我查看了服务器日志: Errno::EIO (Input/output error @ io_write – ): 我在网上寻找这个 – 这是一个IO连接问题,在我的情况下的原因应该是产生美洲狮的父进程已经完成但是puma试图记录它的东西。 所以我使用重定向,希望控制台没问题: puma -e production -p 3000 > log/console.log & 但问题仍然存在。 到目前为止,我认为它只与omniauth有关:它总是记录到stdout,即使我这样做“ https://github.com/intridea/omniauth/issues/583 ”。 所以现在我想我可以尝试更改omniauth的记录器或尝试“给stdout”到omniauth,即使它在后台运行 非常感谢:)

将设计和omniauth处理为失败的Google oauth2

我正在尝试配置一个新的rails4.2应用来对Google Oauth2进行身份validation。 我似乎成功地完成了整个过程,但它被视为失败。 最初的授权似乎进展顺利,直到谷歌发送回调。 然后它似乎被错误地识别为失败。 给出的错误消息是: Could not authenticate you from Google because “Invalid credentials”. 我已经google了解决方案,但无济于事。 是否可以打开其他日志记录以了解它为什么选择通过故障方法进行处理? 这是请求的日志: Started GET “/users/auth/google” for 127.0.0.1 at 2016-04-17 09:37:33 +0800 Started GET “/users/auth/google/callback?state=<>&code=<>” for 127.0.0.1 at 2016-04-17 09:37:45 +0800 Processing by Users::OmniauthCallbacksController#failure as HTML Parameters: {“state”=>”<>”, “code”=>”<>”} Redirected to http://test_app.dev/sign_in Completed 302 Found in 1ms (ActiveRecord: 0.0ms) 在测试时,我点击了谷歌提示我的时候允许,并且url看起来很好,那么为什么这个被处理好像是失败的呢? […]

使用Rails的omniauth成功登录后保存Comment对象

在用户通过omn​​iauth (Twitter,Facebook或OpenID)成功登录后,我希望rails更新或存储Comment。 A(未登录)用户填写评论表单。 post那个。 用户获得一个omniauth页面,她可以选择登录方式:Twitter,Facebook或OpenID。 一旦用户成功从oAuth返回,我想存储(或发布)Comment。 我有这个工作,使用会话变量,但这不是非常线程安全的:如果用户有多个评论标签打开与相同的会话,它将中断。 我应该以未发布的状态将注释保存到数据库,并在返回后切换它吗? 如果是这样,如何知道如何切换正确的评论? 问题类似于上述会话问题。 有没有办法简单地传递comment-object和omniauth,并在用户从成功登录返回时收回它? 或者我可以传递一些哈希字符串,我可以在成功返回后提取? 编辑:完成重写以简化和澄清问题。

在rails应用程序中使用OmniAuth时,为什么我总是遇到Errno :: ETIMEDOUT

我有一个rails虚拟应用程序,我已经将OmniAuth添加到我的Gemfile中。 我补充说 在我的应用程序布局文件中 我还在config \ initializers文件夹中添加了omniauth.rb文件。 Rails.application.config.middleware.use OmniAuth::Builder do provider :twitter, ‘MYKEY’, ‘MYSECERT’ end 用rails s重新启动rails服务器后,访问http:// localhost:3000 / auth / twitter 我总是遇到Errno::ETIMEDOUT ,说Operation timed out – connect(2) 我的电脑可以同时访问Twitter网站。 任何人都可以帮我解决这里出了什么问题吗? 非常感谢你。

为什么twitter oauth访问令牌无效/过期(rails 3)

过去三天我一直试图解决这个问题,但无济于事。 我所要做的就是允许使用Twitter登录的用户向他们的帐户发推文。 这是我要解决的错误消息: Twitter::Error::Unauthorized in PostsController#create Invalid or expired token 我尝试了各种不同的东西,但我回到了完整的360圈到同一条消息。 这就是我现在所处的位置: class ApplicationController provider.token, :secret => provider.secret) rescue nil end @twitter_user end 这是抛出错误的地方 class PostsController < ApplicationController def create twitter.update(@post.content) end 这是模式的布局方式 create_table “authentications”, :force => true do |t| t.integer “user_id” t.string “provider” t.string “uid” t.datetime “created_at”, :null => false t.datetime “updated_at”, :null => […]

Rails:使用OmniAuth(FB授权),从Facebook Hash读取数据

使用OmniAuth,我成功从Facebook获取哈希数据:存储在“auth”中 # extra=#] last_name=”Jordan” link=”http://www.facebook.com/michael” locale=”en_US” middle_name=”Ball” name=”Michael Jordan” quotes=”\”lalala\”\n\n\”lala\”” timezone=9 updated_time=”2011-09-01T20:25:58+0000″ username=”mjordan82″ verified=true>> info=# verified=true> provider=”facebook” uid=”123456879″> 在用户模型中,我执行如下操作: def self.create_with_omniauth(auth) create! do |user| user.provider = auth[“provider”] user.uid = auth[“uid”] user.name = auth[“name”] end end 当我检查数据库时,我只有提供者和uid。 User.name行为空。 从测试中,我发现我无法存储除提供者和uid之外的其他数据。 例如,user.name = auth [“provider”]或user.name = auth [“uid”]存储没有问题,但是当我尝试类似user.name = auth [“timezone”]或user.name =时auth [“last_name”],没有任何内容存储在变量中。 有人知道怎么修这个东西吗? 我也试过user.name = auth [“user_info”] […]

使用“omniauth-oauth2”捆绑安装错误

运行bundle install我收到以下错误(完整跟踪: http : //pastebin.com/Vp4nHc2p ): Bundler could not find compatible versions for gem “omniauth-oauth2”: In Gemfile: omniauth-facebook (~> 1.2.0) ruby depends on omniauth-oauth2 (~> 1.0.0) ruby omniauth-github (~> 1.0.1) ruby depends on omniauth-oauth2 (1.1.1) 要查看我的Gemfile: http ://pastebin.com/vMcHDHa8 知道怎么解决吗?