4 ruby api ruby-on-rails netflix
我试图将oauth与rares-branch Ruby gem一起使用.我一直收到错误:
OAuth的实例:: Consumer需要有方法`marshal_load'
我的代码,activate.rb如下.有关如何解决此问题的任何想法?谢谢!-Henry
require 'oauth/consumer'
def index
@consumer = OAuth::Consumer.new("CONSUMER KEY","CONSUMER SECRET", {
:site => "http://api.netflix.com",
:request_token_url => "https://api-user.netflix.com/oauth/request_token",
:access_token_url => "http://api.netflix.com/oauth/access_token",
:authorize_url => "https://api-user.netflix.com/oauth/login",
:application_name => "AppName"})
@request_token = @consumer.get_request_token
session[:request_token]=@request_token
session[:request_token_secret]=@request_token.secret
@authorize_url = @request_token.authorize_url({
:oauth_consumer_key => "CONSUMER KEY"
:application_name => "AppName",
:oauth_callback => "http://localhost:3000/activate/callback"
})
redirect_to @authorize_url
end
def callback
@request_token=OAuth::RequestToken.new(session[:request_token],
session[:request_token_secret])
@access_token = @request_token.get_access_token
end
Run Code Online (Sandbox Code Playgroud)
令牌不可序列化,因此您无法将其存储在会话中.改为将令牌密钥和密钥单独存储在会话中,并在需要时再次使用密钥和密钥创建新的OAuthToken.
您可能需要清除会话存储以删除已放入其中的令牌.