Web 上の Rails アプリで omniauth が問題なく動作しています。また、iPhone アプリが対話するための API を作成し、omniauth を機能させようとしています。
アクセス トークン (Facebook.app との統合された iOS 統合から受け取った) を omniauth に渡して、データベースにプロバイダー エントリを作成する方法はありますか?
現在、私のWebアプリには、次のコードを含む認証コントローラーがあります
def create
omniauth = request.env["omniauth.auth"]
user = User.where("authentications.provider" => omniauth['provider'], "authentications.uid" => omniauth['uid']).first
if user
session[:user_id] = user.id
flash[:notice] = t(:signed_in)
redirect_to root_path
elsif current_user
user = User.find(current_user.id)
user.apply_omniauth(omniauth)
user.save
flash[:notice] = t(:success)
redirect_to root_path
else
session[:omniauth] = omniauth.except('extra')
flash[:notice] = "user not found, please signup, or login. Authorization will be applied to new account"
redirect_to register_path
end
end