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