現在、omniauth を使用してユーザーを認証しています。これは、私のセッション コントローラーでは次のようになり、うまく機能します。
def create
auth = request.env['omniauth.auth']
unless @auth = Authentication.find_from_hash(auth)
# Create a new user or add an auth to existing user, depending on
# whether there is already a user signed in.
@auth = Authentication.create_from_hash(auth, current_user)
end
# Log the authorizing user in.
self.current_user = @auth.user
redirect_to authentications_url, :notice => "You've signed in!"
end
この後、Twitter の uid を認証テーブルに保存し (Linkedin、Facebook も使用しています) 、Twitter セッションが閉じられたと思います。
Twitter gem を使用できるように認証するにはどうすればよいですか? omniauth コールバックの直後に呼び出すとしたら、このようになるはずです。
token = auth['credentials']['token'],
secret = auth['credentials']['secret']
Twitter.oauth_token = token
Twitter.oauth_token_secret = secret
セッションを再起動して、トークンとシークレットを適切な場所に配置する必要があることは明らかです。これを行うメソッドを作成するにはどうすればよいですか?