omniauth-etrade 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -13
- data/lib/omniauth-etrade/version.rb +1 -1
- data/lib/omniauth/strategies/etrade.rb +30 -62
- data/omniauth-etrade.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75205eeaf38a8a968abb19ee94266286444bbece
|
4
|
+
data.tar.gz: d76032be348d24b3e7e8a4776e11c4a23c694e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
7
|
+
Add the strategy to your application's Gemfile:
|
9
8
|
|
10
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-etrade'
|
11
|
+
```
|
11
12
|
|
12
13
|
And then execute:
|
13
14
|
|
14
|
-
|
15
|
+
```ruby
|
16
|
+
bundle
|
17
|
+
```
|
15
18
|
|
16
19
|
Or install it yourself as:
|
17
20
|
|
18
|
-
|
21
|
+
```ruby
|
22
|
+
gem install omniauth-etrade
|
23
|
+
```
|
19
24
|
|
20
25
|
## Usage
|
21
26
|
|
22
|
-
|
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
|
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
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
|
-
{ '
|
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
|
data/omniauth-etrade.gemspec
CHANGED
@@ -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@
|
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.
|
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:
|
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@
|
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.
|
162
|
+
rubygems_version: 2.0.0
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: OmniAuth strategy of E*TRADE
|