reddit-omniauth gem getting"您发送了无效请求 - 请求无效范围"

时间:2016-11-08 20:25:24

标签: ruby-on-rails oauth-2.0 omniauth reddit

我正在尝试使用omniauth-reddit

在rails应用程序中实现reddit登录

登录是成功的,但我不会在哪里出错

enter image description here

  

我的OmniauthCallbacksController.rb文件

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def reddit_oauth2
    @user = User.from_omniauth(request.env["omniauth.auth"])
    sign_in_and_redirect root_path
  end
  

我的用户模型

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
  devise :omniauthable, :omniauth_providers => [:reddit]
  def self.from_omniauth(auth)
    where(provider: auth.provider,uid: auth.id).first_or_create do |user|
      user.provider = auth.provider
      user.id = auth.id
      user.password = Devise.friendly_token[0,20]
    end
  end
end

can anybody suggest me scope or solution ??先谢谢

0 个答案:

没有答案