Rails为coinbase设置oauth2

时间:2013-12-19 05:47:44

标签: ruby-on-rails ruby oauth oauth-2.0

我是oauth的新手,我试图在rails中设置oauth2。但每当我跑rails s时,我都会得到。

Couldn't get a file descriptor referring to the console
Enter the code returned in the URL: 

我安装了gem并将此代码添加到/config/application.rb

require 'oauth2'
redirect_uri = 'my.herokuapp.com/callback'
client = OAuth2::Client.new('eeeeeeeee', 'aaaaaaaaaa', site: 'https://coinbase.com')
`open "#{client.auth_code.authorize_url(redirect_uri: redirect_uri)}"`
print "Enter the code returned in the URL: "
code = STDIN.readline.chomp
token = client.auth_code.get_token(code, redirect_uri: redirect_uri)
puts JSON.parse(token.get('/api/v1/account/balance').body)

我在本地运行这个,我指着我的herokuapp。我究竟做错了什么? I'm follwing the tutorial on this page.

1 个答案:

答案 0 :(得分:0)

Rubygems上的gem版本是2.0之前的OAuth

使用gem 'coinbase', :git => 'git://github.com/coinbase/coinbase-ruby.git'

另见:https://github.com/coinbase/coinbase-ruby/issues/38