omniauth-etrade 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 386beef791f783891844e963ac2ce7b6a634899f
4
- data.tar.gz: 2d6041c347a70b0a8b09139d9714d602492c0759
3
+ metadata.gz: 75205eeaf38a8a968abb19ee94266286444bbece
4
+ data.tar.gz: d76032be348d24b3e7e8a4776e11c4a23c694e3b
5
5
  SHA512:
6
- metadata.gz: 47209b5e279d7872c54df88a68070df31135dd6a7e4578c683027f94570637b4b7b1af0d966a84cf1a807f8406f4b1b96c8ddb3964cd477c4c7500991370fc86
7
- data.tar.gz: 6ac4028328559dda45499e51bd909ec33cf3621a507a8977db90377e7dad28c07db09cd8672f47581e12b3db5006bdb76bdb2062051f269cb929d52ccf2f5b72
6
+ metadata.gz: 7597c7bb1b3601650cc7e1e25e7ab997cd23418e80ed6e980814b9c6f7f6d515f8b7cfcd526de7779315c000b016c5ca5d34f6f955b51350a291d3ae3b5ce8df
7
+ data.tar.gz: 34bf1d6abeaa1666db2bcd7d7db4f3ae4814874f22cc9768a85f981c0f891251ff19d995ee66db04d5304f5f985b67354b77c645948ad09b56f0b5eab6380dca
data/README.md CHANGED
@@ -1,25 +1,50 @@
1
- <<<<<<< HEAD
2
1
  # Omniauth::Etrade
3
2
 
4
- TODO: Write a gem description
3
+ This is the official OmniAuth strategy for authenticating with E*Trade's API. To use it, you'll need a consumer key and consumer secret which can be obtained from E*Trade (more information available at [developer.etrade.com](https://developer.etrade.com/))
5
4
 
6
5
  ## Installation
7
6
 
8
- Add this line to your application's Gemfile:
7
+ Add the strategy to your application's Gemfile:
9
8
 
10
- gem 'omniauth-etrade'
9
+ ```ruby
10
+ gem 'omniauth-etrade'
11
+ ```
11
12
 
12
13
  And then execute:
13
14
 
14
- $ bundle
15
+ ```ruby
16
+ bundle
17
+ ```
15
18
 
16
19
  Or install it yourself as:
17
20
 
18
- $ gem install omniauth-etrade
21
+ ```ruby
22
+ gem install omniauth-etrade
23
+ ```
19
24
 
20
25
  ## Usage
21
26
 
22
- TODO: Write usage instructions here
27
+ Once installation is complete. Integrate the strategy into your middleware:
28
+
29
+ ```ruby
30
+ use OmniAuth::Builder do
31
+ provider :etrade, ENV['CONSUMER_KEY'], ENV['CONSUMER_SECRET']
32
+ end
33
+ ```
34
+
35
+ In Rails, you'll want to add to the middleware stack:
36
+
37
+ ```ruby
38
+ Rails.application.config.middleware.use OmniAuth::Builder do
39
+ provider :etrade, ENV['CONSUMER_KEY'], ENV['CONSUMER_SECRET']
40
+ end
41
+ ```
42
+
43
+ If using devise, you'll want to declare provider in your config\initializers\devise.rb:
44
+
45
+ ```ruby
46
+ config.omniauth :etrade, ENV['CONSUMER_KEY'], ENV['CONSUMER_SECRET']
47
+ ```
23
48
 
24
49
  ## Contributing
25
50
 
@@ -28,9 +53,3 @@ TODO: Write usage instructions here
28
53
  3. Commit your changes (`git commit -am 'Add some feature'`)
29
54
  4. Push to the branch (`git push origin my-new-feature`)
30
55
  5. Create new Pull Request
31
- =======
32
- omniauth-etrade
33
- ===============
34
-
35
- OmniAuth strategy for etrade
36
- >>>>>>> f25330067f94cde611f7e70695801b6da0fcda0a
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Etrade
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -3,83 +3,51 @@ require 'omniauth-oauth'
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  class Etrade < OmniAuth::Strategies::OAuth
6
-
6
+
7
7
  option :client_options, {
8
8
  :site => 'https://etws.etrade.com',
9
9
  :authorize_url => 'https://us.etrade.com/e/t/etws/authorize',
10
10
  :request_token_url => 'https://etws.etrade.com/oauth/request_token',
11
- :access_token_url => 'https://etws.etrade.com/oauth/access_token'
11
+ :access_token_url => 'https://etws.etrade.com/oauth/access_token',
12
+ # default http_method for oauth gem is post, however etrade requires this
13
+ # to be get
14
+ :http_method => :get
12
15
  }
13
16
 
14
17
  def callback_url
15
18
  'oob'
16
19
  end
17
-
18
- def request_phase
19
- request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
20
- session['oauth'] ||= {}
21
- session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
22
-
23
- if request_token.callback_confirmed?
24
- redirect request_token.authorize_url({key: options.consumer_key}.merge(options[:authorize_params])).sub! 'oauth_token', 'token'
25
- else
26
- redirect request_token.authorize_url(options[:authorize_params].merge(oauth_callback: callback_url, key: options.consumer_key)).sub! 'oauth_token', 'token'
27
- end
28
-
29
- rescue ::Timeout::Error => e
30
- fail!(:timeout, e)
31
- rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
32
- fail!(:service_unavailable, e)
33
- end
34
-
35
- def callback_phase
36
- raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?
37
-
38
- Rails.logger.debug(session['oauth'].to_yaml)
39
20
 
40
- request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret'))
41
-
42
- opts = {}
43
- if session['oauth'][name.to_s]['callback_confirmed']
44
- opts[:oauth_verifier] = request['oauth_verifier']
45
- else
46
- opts[:oauth_callback] = callback_url
47
- end
48
-
49
- @access_token = request_token.get_access_token(opts)
50
-
51
- super
52
- rescue ::Timeout::Error => e
53
- fail!(:timeout, e)
54
- rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
55
- fail!(:service_unavailable, e)
56
- rescue ::OAuth::Unauthorized => e
57
- fail!(:invalid_credentials, e)
58
- rescue ::MultiJson::DecodeError => e
59
- fail!(:invalid_response, e)
60
- rescue ::OmniAuth::NoSessionError => e
61
- fail!(:session_expired, e)
62
- end
63
-
64
- uid { raw_info['uid'] }
21
+ def request_phase
22
+ begin
23
+ request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
24
+ session['oauth'] ||= {}
25
+ session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?,
26
+ 'request_token' => request_token.token, 'request_secret' => request_token.secret}
27
+
28
+ Rails.logger.debug { "#{request_token.to_yaml}" }
29
+
30
+ if request_token.callback_confirmed?
31
+ redirect request_token.authorize_url({key: options.consumer_key}.merge(options[:authorize_params])).sub! 'oauth_token', 'token'
32
+ else
33
+ redirect request_token.authorize_url(
34
+ options[:authorize_params].merge(oauth_callback: callback_url, key: options.consumer_key)).sub! 'oauth_token', 'token'
35
+ end
36
+ rescue ::Timeout::Error => e
37
+ fail!(:timeout, e)
38
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
39
+ fail!(:service_unavailable, e)
40
+ end
41
+ end
65
42
 
66
- info do
67
- {
68
- 'uid' => raw_info['uid'],
69
- 'name' => raw_info['display_name'],
70
- 'email' => raw_info['email']
71
- }
43
+ def callback_phase
44
+ super
72
45
  end
73
46
 
74
47
  extra do
75
- { 'raw_info' => raw_info }
48
+ { 'access_token' => access_token }
76
49
  end
77
50
 
78
- def raw_info
79
- Rails.logger.debug(access_token.to_yaml)
80
- @raw_info ||= MultiJson.decode(access_token.get('/1/account/info').body)
81
- end
82
-
83
51
  end
84
52
  end
85
- end
53
+ end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.name = "omniauth-etrade"
9
9
  spec.version = OmniAuth::Etrade::VERSION
10
10
  spec.authors = ["Athens Holloway"]
11
- spec.email = ["athens@uvest.co"]
11
+ spec.email = ["athens@logicart.co"]
12
12
  spec.description = %q{OmniAuth strategy of E*TRADE}
13
13
  spec.summary = %q{OmniAuth strategy of E*TRADE}
14
14
  spec.homepage = "https://github.com/uvest/omniauth-etrade"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-etrade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Athens Holloway
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-25 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -124,7 +124,7 @@ dependencies:
124
124
  version: '0'
125
125
  description: OmniAuth strategy of E*TRADE
126
126
  email:
127
- - athens@uvest.co
127
+ - athens@logicart.co
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.0.3
162
+ rubygems_version: 2.0.0
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: OmniAuth strategy of E*TRADE