如何与omniauth做同样的事情
阅读此oauth 教程。
我想使用 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
有人知道如何实现这一点吗?
Reading on this oauth tutorial.
I would like to do exactly the same thing using the Omniauth gem, to get the access tokens from Twitter's 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
Anyone know how this can be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个很好的方法,请看一下:
http://philsturgeon.co.uk/blog/2010/11/using-omniauth-to-make-twitteroauth-api-requests
Here it is a good howto, take a look:
http://philsturgeon.co.uk/blog/2010/11/using-omniauth-to-make-twitteroauth-api-requests