omniauth-freshbooks-oauth2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58911d48ea8425c35b9b3c595beca0110b0a4cd5
4
+ data.tar.gz: bbffa187581950a51deffe7044e19f2f9ea7e1d7
5
+ SHA512:
6
+ metadata.gz: bb752abc8243ce861aec620dc91cf066791429c4c8a2d24600c3d6ade7d1028bc8eb5e7ef48e9c3a459891623e8b4ab189f05b5465c71fa81a83891f00256f66
7
+ data.tar.gz: dd5fcdec9f2c64baa7d0e84697d6ee9c2e9cca67d762ef773bed85ecbfe566b5ee674ad0b9d85a1741114e33c488ab4017cc4a2c03dc05f72ba4256fb6f0d713
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ /*.gem
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ group :development do
6
+ gem 'rubocop', '> 0.25'
7
+ end
8
+
9
+ group :test do
10
+ gem 'coveralls', :require => false
11
+ gem 'rack-test'
12
+ gem 'rspec', '~> 3.1.0'
13
+ gem 'simplecov', :require => false
14
+ end
15
+
16
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-freshbooks-oauth2 (0.0.1)
5
+ omniauth (~> 1.2)
6
+ omniauth-oauth2 (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.3.0)
12
+ coveralls (0.8.15)
13
+ json (>= 1.8, < 3)
14
+ simplecov (~> 0.12.0)
15
+ term-ansicolor (~> 1.3)
16
+ thor (~> 0.19.1)
17
+ tins (>= 1.6.0, < 2)
18
+ diff-lcs (1.2.5)
19
+ docile (1.1.5)
20
+ faraday (0.12.2)
21
+ multipart-post (>= 1.2, < 3)
22
+ hashie (3.5.7)
23
+ json (2.0.2)
24
+ jwt (1.5.6)
25
+ multi_json (1.13.1)
26
+ multi_xml (0.6.0)
27
+ multipart-post (2.0.0)
28
+ oauth2 (1.4.0)
29
+ faraday (>= 0.8, < 0.13)
30
+ jwt (~> 1.0)
31
+ multi_json (~> 1.3)
32
+ multi_xml (~> 0.5)
33
+ rack (>= 1.2, < 3)
34
+ omniauth (1.8.1)
35
+ hashie (>= 3.4.6, < 3.6.0)
36
+ rack (>= 1.6.2, < 3)
37
+ omniauth-oauth2 (1.5.0)
38
+ oauth2 (~> 1.1)
39
+ omniauth (~> 1.2)
40
+ parser (2.3.1.4)
41
+ ast (~> 2.2)
42
+ powerpack (0.1.1)
43
+ rack (2.0.1)
44
+ rack-test (0.6.3)
45
+ rack (>= 1.0)
46
+ rainbow (2.1.0)
47
+ rake (11.3.0)
48
+ rspec (3.1.0)
49
+ rspec-core (~> 3.1.0)
50
+ rspec-expectations (~> 3.1.0)
51
+ rspec-mocks (~> 3.1.0)
52
+ rspec-core (3.1.7)
53
+ rspec-support (~> 3.1.0)
54
+ rspec-expectations (3.1.2)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.1.0)
57
+ rspec-mocks (3.1.3)
58
+ rspec-support (~> 3.1.0)
59
+ rspec-support (3.1.2)
60
+ rubocop (0.43.0)
61
+ parser (>= 2.3.1.1, < 3.0)
62
+ powerpack (~> 0.1)
63
+ rainbow (>= 1.99.1, < 3.0)
64
+ ruby-progressbar (~> 1.7)
65
+ unicode-display_width (~> 1.0, >= 1.0.1)
66
+ ruby-progressbar (1.8.1)
67
+ simplecov (0.12.0)
68
+ docile (~> 1.1.0)
69
+ json (>= 1.8, < 3)
70
+ simplecov-html (~> 0.10.0)
71
+ simplecov-html (0.10.0)
72
+ term-ansicolor (1.4.0)
73
+ tins (~> 1.0)
74
+ thor (0.19.1)
75
+ tins (1.12.0)
76
+ unicode-display_width (1.1.1)
77
+
78
+ PLATFORMS
79
+ ruby
80
+
81
+ DEPENDENCIES
82
+ coveralls
83
+ omniauth-freshbooks-oauth2!
84
+ rack-test
85
+ rake
86
+ rspec (~> 3.1.0)
87
+ rubocop (> 0.25)
88
+ simplecov
89
+
90
+ BUNDLED WITH
91
+ 1.16.0
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # OmniAuth FreshBooks OAuth2
2
+
3
+ This is the OmniAuth OAuth2 strategy for authentication to [FreshBooks](https://www.freshbooks.com/api/authentication).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-freshbooks-oauth2'
11
+ ```
12
+
13
+ And then, you need to add the following to your `config/initializers/omniauth.rb`:
14
+
15
+ ```ruby
16
+ Rails.application.config.middleware.use OmniAuth::Builder do
17
+ provider :freshbooks, ENV['FRESHBOOKS_KEY'], ENV['FRESHBOOKS_SECRET']
18
+ end
19
+ ```
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :test => :spec
7
+
8
+ begin
9
+ require 'rubocop/rake_task'
10
+ RuboCop::RakeTask.new
11
+ rescue LoadError
12
+ task :rubocop do
13
+ $stderr.puts 'Rubocop is disabled'
14
+ end
15
+ end
16
+
17
+ task :default => [:spec, :rubocop]
@@ -0,0 +1,2 @@
1
+ require 'omniauth/freshbooks/version'
2
+ require 'omniauth/strategies/freshbooks'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Freshbooks
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Freshbooks < OmniAuth::Strategies::OAuth2
6
+ API_VERSION = 'alpha'.freeze
7
+
8
+ option :name, 'freshbooks'
9
+
10
+ option :client_options, {
11
+ site: 'https://api.freshbooks.com',
12
+ authorize_url: 'https://my.freshbooks.com/service/auth/oauth/authorize',
13
+ token_url: 'https://api.freshbooks.com/auth/oauth/token'
14
+ }
15
+
16
+ option :token_params, {
17
+ headers: { 'Api-Version' => API_VERSION }
18
+ }
19
+
20
+ uid { raw_info['id'] }
21
+
22
+ info do
23
+ {
24
+ email: raw_info['email'],
25
+ first_name: raw_info['name'],
26
+ last_name: raw_info['name']
27
+ }
28
+ end
29
+
30
+ extra do
31
+ {
32
+ 'raw_info' => raw_info
33
+ }
34
+ end
35
+
36
+ def raw_info
37
+ @raw_info ||= access_token
38
+ .get('auth/api/v1/users/me', { headers: { 'Api-Version' => API_VERSION } })
39
+ .parsed['response']
40
+ end
41
+
42
+ def callback_url(include_query_string = true)
43
+ url = full_host + script_name + callback_path
44
+
45
+ # Optional inclusion of query_string ensure the access token request redirect_uri is an exact match to the
46
+ # authorized redirect URI defined in FreshBooks
47
+ url += query_string if include_query_string
48
+
49
+ # Ensure valid request for localhost because FreshBooks doesn't authorize non ssl callbacks.
50
+ # The ssl response can then be altered from https:// to http:// manually for the purpose of testing.
51
+ # This is limitation is noted in "Redirect URI Limitations" section of their documentation:
52
+ # https://www.freshbooks.com/api/authentication
53
+ url.gsub('http://localhost', 'https://localhost')
54
+ end
55
+
56
+ def build_access_token
57
+ client.auth_code.get_token(
58
+ request.params["code"],
59
+ { redirect_uri: callback_url(false) }.merge(token_params.to_hash(symbolize_keys: true)),
60
+ deep_symbolize(options.auth_token_params)
61
+ )
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/freshbooks/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'omniauth-freshbooks-oauth2'
7
+ spec.version = OmniAuth::Freshbooks::VERSION
8
+ spec.authors = ['Kevin Pheasey']
9
+ spec.email = ['kevin@kpheasey.com']
10
+ spec.summary = 'FreshBooks OAuth2 strategy for OmniAuth'
11
+ spec.description = 'FreshBooks OAuth2 strategy for OmniAuth using the new FreshBooks API'
12
+ spec.homepage = 'https://github.com/kp-software/omniauth-freshbooks-oauth2'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency 'omniauth', '~> 1.2'
23
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
24
+
25
+ spec.add_development_dependency 'rake', '~> 11.3'
26
+ spec.add_development_dependency 'rspec', '~> 3.1'
27
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-freshbooks-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Pheasey
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-23 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ description: FreshBooks OAuth2 strategy for OmniAuth using the new FreshBooks API
70
+ email:
71
+ - kevin@kpheasey.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - README.md
80
+ - Rakefile
81
+ - lib/omniauth-freshbooks.rb
82
+ - lib/omniauth/freshbooks/version.rb
83
+ - lib/omniauth/strategies/freshbooks.rb
84
+ - omniauth-freshbooks-oauth2.gemspec
85
+ homepage: https://github.com/kp-software/omniauth-freshbooks-oauth2
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.6.14
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: FreshBooks OAuth2 strategy for OmniAuth
109
+ test_files: []