我设置我的应用程序类似于这里的教程 - http://railscasts.com/episodes/235-devise-and-omniauth-revised。如果您无法访问它,以下是我的代码
Omniauth 控制器回调
def all
user = User.from_omniauth(request.env["omniauth.auth"])
if user.persisted?
flash.notice = "Signed in!"
sign_in_and_redirect user
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
alias_method :twitter, :all
end
用户模型
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.username = auth.info.nickname
user.name = auth.info.name
end
end
def self.new_with_session(params, session)
if session["devise.user_attributes"]
new(session["devise.user_attributes"], without_protection: true) do |user|
user.attributes = params
user.valid?
end
else
super
end
end
现在我想知道如何获取经过身份验证的用户的 oauth 令牌和 oauth 令牌秘密?
谢谢