omniauth-td-ameritrade 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 852b47bce9f72d2442eb5a4cc9ed131258cf3c2b
4
+ data.tar.gz: 960875669590a2c407d995aaa3f92f74e66aadf6
5
+ SHA512:
6
+ metadata.gz: 3e9ff3c7c41269640a3555bd9de6798e349d45e91662492807965524249df2f76899b5b88cdbc530ea3a719f877346e052d53ba439f16898dcc264313acc40b9
7
+ data.tar.gz: 5ea9108c28e5d3be8b226ddfc540097df3d698f7d456cbb3bcc1262132710c976c7c72536b5b0d3d2af4e71de4f3c67553daa0510e13a6c005bb1586eb0af16d
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-td-ameritrade.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # Omniauth::Td::Ameritrade
2
+
3
+ An omni-auth strategy to authenticate with TD Ameritrade's developer API.
4
+
5
+ Get your API key at: [https://developer.tdameritrade.com](https://developer.tdameritrade.com)
6
+
7
+ Note that TD Ameritrade only provides Client ID.
8
+ No Client Secret is provided or necessary when making the API call.
9
+
10
+ This implementation is useful when you need your access tokens automatically refreshed for servers that manage your portfolio.
11
+
12
+ I am doubtful, users would really be keen to login to your system and allow you direct access their portfolio's management
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'omniauth-td-ameritrade'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install omniauth-td-ameritrade
27
+
28
+ ## Usage
29
+
30
+ Here's an example for adding the middleware to a Rails app in config/initializers/omniauth.rb:
31
+
32
+ ```
33
+ Rails.application.config.middleware.use OmniAuth::Builder do
34
+ provider :amtd, ENV['AMERITRADE_CLIENT_ID'], nil
35
+ end
36
+ ```
37
+
38
+
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-td-ameritrade/fork )
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/td_ameritrade'
@@ -0,0 +1,39 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Amtd < OmniAuth::Strategies::OAuth2
6
+
7
+ option :name, 'amtd'
8
+
9
+ option :client_options, {
10
+ :site => "https://api.tdameritrade.com",
11
+ :authorize_url => "https://auth.tdameritrade.com/auth",
12
+ :token_url => "https://api.tdameritrade.com/v1/oauth2/token"
13
+ }
14
+
15
+ uid { raw_info[0]["securitiesAccount"]["accountId"] }
16
+
17
+ info do
18
+ {
19
+ :email => "#{raw_info[0]["securitiesAccount"]["accountId"]}@tdameritrade.com", # Fake email to allow saving
20
+ :cash_balance => raw_info[0]["securitiesAccount"]["currentBalances"]["cashBalance"],
21
+ :long_market_value => raw_info[0]["securitiesAccount"]["currentBalances"]["longMarketValue"]
22
+ }
23
+ end
24
+
25
+ def client
26
+ combined_client_id = "#{options.client_id}@AMER.OAUTHAP"
27
+ ::OAuth2::Client.new(combined_client_id, options.client_secret, deep_symbolize(options.client_options))
28
+ end
29
+
30
+ def raw_info
31
+ @raw_info ||= access_token.get("/v1/accounts").parsed
32
+ end
33
+
34
+ def callback_url
35
+ full_host + script_name + callback_path
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/td_ameritrade'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module TdAmeritrade
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/td_ameritrade/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-td-ameritrade"
8
+ spec.version = Omniauth::TdAmeritrade::VERSION
9
+ spec.authors = ["Gary Teh"]
10
+ spec.email = ["garyjob@gmail.com"]
11
+ spec.summary = %q{A TD Ameritrade OAuth2 strategy for OmniAuth 1.x}
12
+ spec.description = %q{A TD Ameritrade OAuth2 strategy for OmniAuth 1.x. This allows you to login to TD Ameritrade with your ruby app.}
13
+ spec.homepage = "https://github.com/garyjob/omniauth-td-ameritrade"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'omniauth', '~> 1.1', '>= 1.1.1'
22
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.5'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency 'rake', '~> 0'
26
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-td-ameritrade
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Gary Teh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: omniauth-oauth2
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.6'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: A TD Ameritrade OAuth2 strategy for OmniAuth 1.x. This allows you to
76
+ login to TD Ameritrade with your ruby app.
77
+ email:
78
+ - garyjob@gmail.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - ".gitignore"
84
+ - Gemfile
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - lib/omniauth-td-ameritrade.rb
89
+ - lib/omniauth/strategies/td_ameritrade.rb
90
+ - lib/omniauth/td_ameritrade.rb
91
+ - lib/omniauth/td_ameritrade/version.rb
92
+ - omniauth-td-ameritrade.gemspec
93
+ homepage: https://github.com/garyjob/omniauth-td-ameritrade
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.6.7
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: A TD Ameritrade OAuth2 strategy for OmniAuth 1.x
117
+ test_files: []