0
目前我使用omniauth验证用户。这看起来像这样在我的会话控制器,并且效果很好:当用户已经登录时,如何为使用Twitter gem和Omniauth gem的用户获取访问令牌?
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宝石?如果我在omniauth回调之后立即调用它,我认为它应该是这样的。
token = auth['credentials']['token'],
secret = auth['credentials']['secret']
Twitter.oauth_token = token
Twitter.oauth_token_secret = secret
我显然需要重新启动会话,并把令牌和秘密在正确的地方。我如何创建一个方法来做到这一点?
未定义的方法'授权'为#<用户:0x007fd5e2081398> – Rob 2014-04-13 17:31:43