Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Commit

Permalink
Upgrade to API v2
Browse files Browse the repository at this point in the history
  • Loading branch information
aianus committed Aug 25, 2015
1 parent c8d29fe commit f1cff58
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/omniauth-coinbase/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module OmniAuth
module Coinbase
VERSION = "1.0.4"
VERSION = "2.0.0"
end
end
17 changes: 8 additions & 9 deletions lib/omniauth/strategies/coinbase.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
require 'omniauth-oauth2'
require 'coinbase'
require 'coinbase/wallet'

module OmniAuth
module Strategies
class Coinbase < OmniAuth::Strategies::OAuth2
option :name, 'coinbase'
option :client_options, {
:site => 'https://coinbase.com',
:site => 'https://www.coinbase.com',
:authorize_url => 'https://www.coinbase.com/oauth/authorize',
:token_url => 'https://www.coinbase.com/oauth/token',
:proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil,
:ssl => {
:verify => true,
:cert_store => ::Coinbase::Client.whitelisted_cert_store
:cert_store => ::Coinbase::Wallet::APIClient.whitelisted_certificates
}
}
option :authorize_options, [:scope, :meta]


uid { raw_info['id'] }
uid { raw_info.id }

info do
{
:id => raw_info['id'],
:name => raw_info['name'],
:email => raw_info['email']
:id => raw_info.id,
:name => raw_info.name
}
end

Expand All @@ -33,11 +32,11 @@ class Coinbase < OmniAuth::Strategies::OAuth2
end

def raw_info
@raw_info ||= MultiJson.load(access_token.get('/api/v1/users').body)['users'][0]['user']
client = ::Coinbase::Wallet::OAuthClient.new(access_token: access_token.token)
@raw_info ||= client.current_user
rescue ::Errno::ETIMEDOUT
raise ::Timeout::Error
end

end
end
end
10 changes: 5 additions & 5 deletions omniauth-coinbase.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ require "omniauth-coinbase/version"
Gem::Specification.new do |s|
s.name = "omniauth-coinbase"
s.version = OmniAuth::Coinbase::VERSION
s.authors = ["Miguel Palhas"]
s.email = ["mpalhas@gmail.com"]
s.homepage = "https://github.com/naps62/omniauth-coinbase"
s.authors = ["Miguel Palhas", "Alex Ianus"]
s.email = ["mpalhas@gmail.com", "hire@alexianus.com"]
s.homepage = "https://github.com/coinbase/omniauth-coinbase"
s.summary = %q{OmniAuth strategy for Coinbase}
s.description = %q{OmniAuth strategy for Coinbase}
s.licenses = ['MIT']
Expand All @@ -21,8 +21,8 @@ Gem::Specification.new do |s|

s.add_dependency 'multi_json', '~> 1.3'
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
s.add_runtime_dependency 'coinbase', '~> 2.0'
s.add_development_dependency 'rspec', '~> 2.7'
s.add_runtime_dependency 'coinbase', '~> 4.0'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'rack-test', '~> 0.6'
s.add_development_dependency 'simplecov', '~> 0.10'
s.add_development_dependency 'webmock', '~> 1.20'
Expand Down
2 changes: 1 addition & 1 deletion spec/omniauth/strategies/coinbase_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it 'should have correct site' do
expect(subject.options.client_options.site).to eq('https://coinbase.com')
expect(subject.options.client_options.site).to eq('https://www.coinbase.com')
end
end
end

0 comments on commit f1cff58

Please sign in to comment.