如何与omniauth相同的事情

时间:2011-05-03 14:26:37

标签: ruby-on-rails twitter oauth omniauth

阅读oauth tutorial

我想使用Omniauth gem做同样的事情,从Twitter的API获取访问令牌。

#oauth = OAuth::Consumer.new(APP_CONFIG['twitter_consumer_key'], APP_CONFIG['twitter_consumer_secret'], :site => 'http://api.twitter.com', :request_endpoint => 'http://api.twitter.com', :sign_in => true)

# Get the request tokens from the API
rt = oauth.get_request_token
rtoken = rt.token # request token
rsecret = rt.secret # request token secret

# Go to url and click ""Allow access” when prompted
# http://api.twitter.com/oauth/authorize?oauth_token=your_request_token_from_above

# Get the access tokens from the API
at = rt.get_access_token
oauth_token = at.token
oauth_token_secret = at.secret

任何人都知道如何实现这一目标?

1 个答案:

答案 0 :(得分:1)