Kの連中をOAuthのトークンを格納することはできませんので、私はdialybooth APIを使用してworkign、およびOAauthので、最初、私はまっすぐは、セッション中に(レール)
#first redirect the user to the authorize_url
redirect_to dailybooth.authorize_url
#on user return grab the code from the query string
dailybooth.oauth_token(params[:code])
#make request to the api
pp dailybooth.get('/users.json')
問題は、それが一定のリダイレクトだろう、だったので、持っていたましたoauth_tokenが設定されているかどうかをチェックしていないので、私はこれを行いました。さて、これはユーザーが許可、dailybooth認可ページに私を送って、その事があればある、(ユーザー情報の配列が返されました)私のページに送られ、私は自分のアカウントへのアクセスを得た
unless dailybooth.oauth_token(params[:code])
#first redirect the user to the authorize_url
redirect_to dailybooth.authorize_url
#on user return grab the code from the query string
dailybooth.oauth_token(params[:code])
end
#make request to the api
pp dailybooth.get('/users.json')
あなたはトークンがもう存在しなかったことをリフレッシュし、ユーザーは再認証する必要がありました。セッションでoauth_tokenを保存するためにだった私が試しだから何
、
if session[:oauth_code] #If session is set
dailybooth.oauth_token(session[:oauth_code]) #sign in using cookie
else
if params[:code]
@oauth_token_ = params[:code]
session[:oauth_code] = @oauth_token_
else
#first redirect the user to the authorize_url
redirect_to dailybooth.authorize_url
end
end
#make request to the api
@info = dailybooth.get('/users.json')
if @info['error']
if @info['error']['error_code']
if @info['error']['error_code'] == 302 #if getting invalid token, request another token.
session[:oauth_code] = nil
#first redirect the user to the authorize_url
redirect_to dailybooth.authorize_url
end
end
end
私が最初に私のウェブサイトに行くとき、私はまだ、同じことを得ている、と私は認証ページにリダイレクトしています私はそのアカウントにアクセスしますが、インデックスに戻ると、oauth_tokenが無効であると表示されます。どんな助け?