ここのチュートリアルと同様にアプリをセットアップします-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トークンシークレットを取得するにはどうすればよいですか?
ありがとう