omniauth-hubspot 0.0.10 → 0.0.11

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: c8399bd54000f6cc86cc09356f31089e387958c4
4
- data.tar.gz: 53481709295bde3090513bd61639b56fd1259987
3
+ metadata.gz: ff582e0a2ff6a180336b6998b1c7441cc08ba30f
4
+ data.tar.gz: 440cc99e40a4e0240c76ca833cebbc4c7f4bd541
5
5
  SHA512:
6
- metadata.gz: a195902781e786d14594cc61513a2555cfddaf2d559730187b384bdfb1b1ea6d59003e28cae1956e278312b6e8dabff747f5522e603e14133e99bfda2f9d3394
7
- data.tar.gz: 528d2d2074ebd43358fa80bc22342095de619170c513edb1c2fefa19181fb13be944b914f08286dc101a2bf824e45d3518e4aab00e27da5deed0e238699337d4
6
+ metadata.gz: acda4f00c15d095d5ab33e61bc45462234a0945ce23d777987cd18ce0da76b617c7f38ad580344eddc9bee6b389b80f569c539b2b6f6cc5b0613a69b58573b90
7
+ data.tar.gz: f27983b51d507be593a6898c8980e65e0f2173f390e0ebb0f4f3bd7c3d9c80fe73a40f7e815b95155d5c0576783f1f26489aa5d344602ea2f74fe023a68226a6
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module HubSpot
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
@@ -1,46 +1,50 @@
1
- require 'omniauth-oauth'
1
+ require 'omniauth-oauth2'
2
2
 
3
3
  module OmniAuth
4
4
  module Strategies
5
- class HubSpot < OmniAuth::Strategies::OAuth
5
+ class HubSpot < OmniAuth::Strategies::OAuth2
6
6
 
7
7
  args [:client_id]
8
8
 
9
9
  option :name, "hubspot"
10
+ option :provider_ignores_state, true
10
11
 
11
12
  option :client_options, {
12
13
  :site => 'https://app.hubspot.com',
13
14
  :authorize_url => '/auth/authenticate'
14
15
  }
15
16
 
16
- def callback_phase
17
- raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?
17
+ option :authorize_options, [:scope, :portalId]
18
+
19
+ attr_accessor :refresh_token
20
+ attr_accessor :expires_in
18
21
 
19
- opts = {}
20
- if session['oauth'][name.to_s]['callback_confirmed']
21
- opts[:oauth_verifier] = request['oauth_verifier']
22
- else
23
- opts[:oauth_callback] = callback_url
22
+ def callback_phase
23
+ if request.params['error'] || request.params['error_reason']
24
+ raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri'])
25
+ end
26
+ if !options.provider_ignores_state && (request.params['state'].to_s.empty? || request.params['state'] != session.delete('omniauth.state'))
27
+ raise CallbackError.new(nil, :csrf_detected)
24
28
  end
25
29
 
26
- @access_token = params[:access_token]
27
- @refresh_token = params[:refresh_token]
28
- @expires_in = params[:expires_in]
30
+ self.access_token = params[:access_token]
31
+
29
32
  super
30
- rescue ::Timeout::Error => e
31
- fail!(:timeout, e)
32
- rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
33
- fail!(:service_unavailable, e)
34
- rescue ::OAuth::Unauthorized => e
33
+ rescue ::OAuth2::Error, CallbackError => e
35
34
  fail!(:invalid_credentials, e)
36
35
  rescue ::MultiJson::DecodeError => e
37
36
  fail!(:invalid_response, e)
38
- rescue ::OmniAuth::NoSessionError => e
39
- fail!(:session_expired, e)
37
+ rescue ::Timeout::Error, ::Errno::ETIMEDOUT, Faraday::Error::TimeoutError => e
38
+ fail!(:timeout, e)
39
+ rescue ::SocketError, Faraday::Error::ConnectionFailed => e
40
+ fail!(:failed_to_connect, e)
40
41
  end
41
42
 
42
43
  credentials do
43
- {'access_token' => @access_token, 'refresh_token' => @refresh_token, 'expires_in' => @expires_in}
44
+ hash = {'token' => access_token}
45
+ hash.merge!('refresh_token' => refresh_token)
46
+ hash.merge!('expires_in' => expires_in)
47
+ hash
44
48
  end
45
49
 
46
50
  end
@@ -3,8 +3,8 @@ require File.expand_path('../lib/omniauth/hubspot/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.add_dependency 'omniauth'
6
- gem.add_dependency 'oauth'
7
- gem.add_dependency 'omniauth-oauth'
6
+ gem.add_dependency 'oauth2'
7
+ gem.add_dependency 'omniauth-oauth2'
8
8
 
9
9
  gem.add_development_dependency 'rspec', '~> 2.7'
10
10
  gem.add_development_dependency 'rack-test'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-hubspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Arnold
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: oauth
28
+ name: oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: omniauth-oauth
42
+ name: omniauth-oauth2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='