omniauth-instagram-graph 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: d4011d4a572fe34b44b58ba89b23562a979ce122695e6c6eccd82c3d0417fb46
4
- data.tar.gz: 4ca610d7d5888a79e766e334a3aa7a2dc49d13b6606a4e5b68cc1aa22d7fc318
3
+ metadata.gz: 280cc32134e9fc71e2832265447a2c7c1f9166ef238d111ae04d5a5e81a55c4c
4
+ data.tar.gz: 2d97ce2c8b383680fc29b3d91b08d98bb40cf13d5229ac855ddaa6b91cfc2da6
5
5
  SHA512:
6
- metadata.gz: 89e02390e96974525d79f5804bd6b9c035ca4988d360e8bfb04f773fbb70108cc96c5e23b85dfd8a64c862b5d22ac6a5d8109ee058dc1715108276b37f44e2f4
7
- data.tar.gz: 4f015b1ef8e9f78a3d5aba5f21feca4ab7233bc1c67e4d5c37a49143aebcd8a5b72ca5e72becfe499cfd735fb94ea6b8f59dedd77d792df06642ebae05e4901d
6
+ metadata.gz: 6e88a62277b168bdc500f6f0b8a98340eb28165b936cdf5206a4fb37973d0b27c842828c8128215b28f8bac9ffee386c6b1177121b167145d41452fecd39d5d1
7
+ data.tar.gz: 0b776b9e14f27e9b32687e3b1d6698c752c1c6427c56a0fe776e65006c5bd1466a7635e84d56c7a7eb7250ae6b41f950711db2e49a14e2212e43d9204c15b8a8
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_gem:
2
+ jetrockets-standard: config/gems.yml
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in omniauth-instagram-graph.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -8,10 +8,16 @@ PATH
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ ast (2.4.0)
11
12
  diff-lcs (1.3)
12
13
  faraday (1.0.0)
13
14
  multipart-post (>= 1.2, < 3)
14
- hashie (3.6.0)
15
+ hashie (4.1.0)
16
+ jaro_winkler (1.5.4)
17
+ jetrockets-standard (1.0.5)
18
+ rubocop-rails (~> 2.3.2)
19
+ rubocop-rspec (~> 1.35.0)
20
+ standard (~> 0.1.9)
15
21
  jwt (2.2.1)
16
22
  minitest (5.14.0)
17
23
  mocha (1.11.2)
@@ -24,13 +30,17 @@ GEM
24
30
  multi_json (~> 1.3)
25
31
  multi_xml (~> 0.5)
26
32
  rack (>= 1.2, < 3)
27
- omniauth (1.9.0)
28
- hashie (>= 3.4.6, < 3.7.0)
33
+ omniauth (1.9.1)
34
+ hashie (>= 3.4.6)
29
35
  rack (>= 1.6.2, < 3)
30
36
  omniauth-oauth2 (1.6.0)
31
37
  oauth2 (~> 1.1)
32
38
  omniauth (~> 1.9)
39
+ parallel (1.19.1)
40
+ parser (2.7.0.4)
41
+ ast (~> 2.4.0)
33
42
  rack (2.2.2)
43
+ rainbow (3.0.0)
34
44
  rake (12.3.3)
35
45
  rspec (3.9.0)
36
46
  rspec-core (~> 3.9.0)
@@ -45,11 +55,31 @@ GEM
45
55
  diff-lcs (>= 1.2.0, < 2.0)
46
56
  rspec-support (~> 3.9.0)
47
57
  rspec-support (3.9.2)
58
+ rubocop (0.79.0)
59
+ jaro_winkler (~> 1.5.1)
60
+ parallel (~> 1.10)
61
+ parser (>= 2.7.0.1)
62
+ rainbow (>= 2.2.2, < 4.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 1.7)
65
+ rubocop-performance (1.5.2)
66
+ rubocop (>= 0.71.0)
67
+ rubocop-rails (2.3.2)
68
+ rack (>= 1.1)
69
+ rubocop (>= 0.72.0)
70
+ rubocop-rspec (1.35.0)
71
+ rubocop (>= 0.60.0)
72
+ ruby-progressbar (1.10.1)
73
+ standard (0.1.10)
74
+ rubocop (~> 0.79.0)
75
+ rubocop-performance (~> 1.5.1)
76
+ unicode-display_width (1.6.1)
48
77
 
49
78
  PLATFORMS
50
79
  ruby
51
80
 
52
81
  DEPENDENCIES
82
+ jetrockets-standard
53
83
  minitest
54
84
  mocha
55
85
  omniauth-instagram-graph!
@@ -57,4 +87,4 @@ DEPENDENCIES
57
87
  rspec (~> 3.0)
58
88
 
59
89
  BUNDLED WITH
60
- 2.1.0
90
+ 2.1.2
data/README.md CHANGED
@@ -74,7 +74,7 @@ Long-Lived Tokens are valid for 60 days. To be able to use token after, you need
74
74
 
75
75
 
76
76
  ``` ruby
77
- client = Omniauth::InstagramGraph::LongLivedClient.new(ENV['INSTAGRAM_APP_ID'], ENV['INSTAGRAM_APP_SECRET'])
77
+ client = OmniAuth::InstagramGraph::LongLivedClient.new(ENV['INSTAGRAM_APP_ID'], ENV['INSTAGRAM_APP_SECRET'])
78
78
  token = client.get_token(access_token: "<CURRENT LONG-LIVED TOKEN>")
79
79
  refreshed = token.refresh
80
80
  ```
@@ -85,4 +85,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
85
85
 
86
86
  ## Code of Conduct
87
87
 
88
- Everyone interacting in the Omniauth::Instagram::Graph project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-instagram-graph/blob/master/CODE_OF_CONDUCT.md).
88
+ Everyone interacting in the OmniAuth::Instagram::Graph project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-instagram-graph/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
3
5
 
@@ -6,4 +8,4 @@ Rake::TestTask.new do |task|
6
8
  task.test_files = FileList['test/*_test.rb']
7
9
  end
8
10
 
9
- task default: :test
11
+ task default: :test
data/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "omniauth/instagram/graph"
4
+ require 'bundler/setup'
5
+ require 'omniauth/instagram/graph'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "omniauth/instagram/graph"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'omniauth/instagram-graph'
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'omniauth/instagram-graph/version'
2
- require 'omniauth/strategies/instagram-graph'
4
+ require 'omniauth/strategies/instagram-graph'
@@ -1,23 +1,25 @@
1
- module Omniauth
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
2
4
  module InstagramGraph
3
- class LongLivedClient < OAuth2::Client
4
- TOKEN_URL = '/access_token'
5
+ class LongLivedClient < OAuth2::Client
6
+ TOKEN_URL = '/access_token'
5
7
 
6
- def initialize(client_id, client_secret, options = {})
7
- options = {
8
- site: "https://graph.instagram.com",
9
- authorize_url: nil,
10
- token_url: TOKEN_URL,
11
- token_method: :get
12
- }.merge!(options)
8
+ def initialize(client_id, client_secret, options = {})
9
+ options = {
10
+ site: 'https://graph.instagram.com',
11
+ authorize_url: nil,
12
+ token_url: TOKEN_URL,
13
+ token_method: :get,
14
+ }.merge!(options)
13
15
 
14
- super(client_id, client_secret, options)
15
- end
16
+ super(client_id, client_secret, options)
17
+ end
16
18
 
17
- def get_token(params = {})
18
- params = { grant_type: 'ig_exchange_token', client_secret: secret }.merge!(params)
19
- super(params, {}, LongLivedToken)
20
- end
21
- end
19
+ def get_token(params = {})
20
+ params = {grant_type: 'ig_exchange_token', client_secret: secret}.merge!(params)
21
+ super(params, {}, LongLivedToken)
22
+ end
23
+ end
22
24
  end
23
25
  end
@@ -1,20 +1,21 @@
1
- module Omniauth
2
- module InstagramGraph
3
- class LongLivedToken < OAuth2::AccessToken
4
- TOKEN_REFRESH_PATH = '/refresh_access_token'
1
+ # frozen_string_literal: true
5
2
 
3
+ module OmniAuth
4
+ module InstagramGraph
5
+ class LongLivedToken < OAuth2::AccessToken
6
+ TOKEN_REFRESH_PATH = '/refresh_access_token'
6
7
 
7
- def refresh(params = {})
8
- options = {
9
- token_url: TOKEN_REFRESH_PATH
10
- }
11
- refresh_client = Omniauth::InstagramGraph::LongLivedClient.new(client.id, client.secret, options)
8
+ def refresh!(params = {})
9
+ options = {
10
+ token_url: TOKEN_REFRESH_PATH,
11
+ }
12
+ refresh_client = OmniAuth::InstagramGraph::LongLivedClient.new(client.id, client.secret, options)
12
13
 
13
- params[:grant_type] = 'ig_refresh_token'
14
- params[:access_token] = token
14
+ params[:grant_type] = 'ig_refresh_token'
15
+ params[:access_token] = token
15
16
 
16
- refresh_client.get_token(params)
17
- end
18
- end
17
+ refresh_client.get_token(params)
18
+ end
19
+ end
19
20
  end
20
- end
21
+ end
@@ -1,5 +1,7 @@
1
- module Omniauth
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
2
4
  module InstagramGraph
3
- VERSION = "1.0.0"
5
+ VERSION = '1.0.1'
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'omniauth/strategies/oauth2'
2
4
  require 'omniauth/instagram-graph/long_lived_token'
3
5
  require 'omniauth/instagram-graph/long_lived_client'
@@ -17,8 +19,8 @@ module OmniAuth
17
19
 
18
20
  option :client_options, {
19
21
  site: 'https://api.instagram.com',
20
- authorize_url: "https://api.instagram.com/oauth/authorize",
21
- token_url: 'oauth/access_token'
22
+ authorize_url: 'https://api.instagram.com/oauth/authorize',
23
+ token_url: 'oauth/access_token',
22
24
  }
23
25
 
24
26
  option :exchange_access_token_to_long_lived, true
@@ -46,9 +48,9 @@ module OmniAuth
46
48
 
47
49
  def info_options
48
50
  params = {}
49
- params.merge!({fields: (options[:info_fields] || 'account_type,id,media_count,username')})
51
+ params[:fields] = (options[:info_fields] || 'account_type,id,media_count,username')
50
52
 
51
- { params: params }
53
+ {params: params}
52
54
  end
53
55
 
54
56
  def callback_url
@@ -69,34 +71,22 @@ module OmniAuth
69
71
  end
70
72
  end
71
73
 
72
- def callback_phase # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength, PerceivedComplexity
73
- error = request.params["error_reason"] || request.params["error"]
74
- if error
75
- fail!(error, CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]))
76
- elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
77
- fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
78
- else
79
- self.access_token = build_access_token
80
-
81
- if options.exchange_access_token_to_long_lived
82
- self.access_token = long_lived_client.get_token(access_token: access_token.token)
83
- end
74
+ protected
75
+
76
+ def build_access_token
77
+ access_token = super
84
78
 
85
- super
79
+ if options.exchange_access_token_to_long_lived
80
+ access_token = long_lived_client.get_token(access_token: access_token.token)
86
81
  end
87
- rescue ::OAuth2::Error, CallbackError => e
88
- fail!(:invalid_credentials, e)
89
- rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
90
- fail!(:timeout, e)
91
- rescue ::SocketError => e
92
- fail!(:failed_to_connect, e)
93
- end
94
82
 
83
+ access_token
84
+ end
95
85
 
96
86
  private
97
87
 
98
88
  def long_lived_client
99
- Omniauth::InstagramGraph::LongLivedClient.new(client.id, client.secret)
89
+ OmniAuth::InstagramGraph::LongLivedClient.new(client.id, client.secret)
100
90
  end
101
91
 
102
92
  def prune!(hash)
@@ -107,4 +97,4 @@ module OmniAuth
107
97
  end
108
98
  end
109
99
  end
110
- end
100
+ end
@@ -1,22 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/omniauth/instagram-graph/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.name = "omniauth-instagram-graph"
5
- spec.version = Omniauth::InstagramGraph::VERSION
6
- spec.authors = ["Igor Alexandrov"]
7
- spec.email = ["igor.alexandrov@gmail.com"]
8
-
9
- spec.summary = "instagram Graph OAuth2 Strategy for OmniAuth"
10
- spec.homepage = "http://github.com/jetrockets/omniauth-instagram-graph"
11
- spec.license = "MIT"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
-
14
- spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = "http://github.com/jetrockets/omniauth-instagram-graph"
16
-
17
- spec.files = `git ls-files`.split("\n")
18
- spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
6
+ spec.name = 'omniauth-instagram-graph'
7
+ spec.version = OmniAuth::InstagramGraph::VERSION
8
+ spec.authors = ['Igor Alexandrov']
9
+ spec.email = ['igor.alexandrov@gmail.com']
10
+
11
+ spec.summary = 'instagram Graph OAuth2 Strategy for OmniAuth'
12
+ spec.homepage = 'http://github.com/jetrockets/omniauth-instagram-graph'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'http://github.com/jetrockets/omniauth-instagram-graph'
18
+
19
+ spec.files = `git ls-files`.split("\n")
20
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
22
  spec.require_paths = ['lib']
21
23
 
22
24
  spec.add_runtime_dependency 'omniauth', '~> 1.9'
@@ -25,4 +27,6 @@ Gem::Specification.new do |spec|
25
27
  spec.add_development_dependency 'minitest'
26
28
  spec.add_development_dependency 'mocha'
27
29
  spec.add_development_dependency 'rake'
30
+
31
+ spec.add_development_dependency 'jetrockets-standard'
28
32
  end
data/test/helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'bundler/setup'
3
4
  require 'minitest/autorun'
@@ -8,7 +9,7 @@ OmniAuth.config.test_mode = true
8
9
 
9
10
  module BlockTestHelper
10
11
  def test(name, &blk)
11
- method_name = "test_#{name.gsub(/\s+/, '_')}"
12
+ method_name = "test_#{name.gsub(/\s+/, "_")}"
12
13
  raise "Method already defined: #{method_name}" if instance_methods.include?(method_name.to_sym)
13
14
  define_method method_name, &blk
14
15
  end
@@ -17,12 +18,12 @@ end
17
18
  module CustomAssertions
18
19
  def assert_has_key(key, hash, msg = nil)
19
20
  msg = message(msg) { "Expected #{hash.inspect} to have key #{key.inspect}" }
20
- assert hash.has_key?(key), msg
21
+ assert hash.key?(key), msg
21
22
  end
22
23
 
23
24
  def refute_has_key(key, hash, msg = nil)
24
25
  msg = message(msg) { "Expected #{hash.inspect} not to have key #{key.inspect}" }
25
- refute hash.has_key?(key), msg
26
+ refute hash.key?(key), msg
26
27
  end
27
28
  end
28
29
 
@@ -53,4 +54,4 @@ class StrategyTestCase < TestCase
53
54
  end
54
55
  end
55
56
  end
56
- end
57
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
  require 'omniauth-instagram-graph'
3
5
  require 'openssl'
@@ -20,4 +22,4 @@ class ClientTest < StrategyTestCase
20
22
  assert_equal 'oauth/access_token', strategy.client.options[:token_url]
21
23
  assert_equal 'https://api.instagram.com/oauth/access_token', strategy.client.token_url
22
24
  end
23
- end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-instagram-graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Alexandrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jetrockets-standard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description:
84
98
  email:
85
99
  - igor.alexandrov@gmail.com
@@ -90,6 +104,7 @@ extensions: []
90
104
  extra_rdoc_files: []
91
105
  files:
92
106
  - ".gitignore"
107
+ - ".rubocop.yml"
93
108
  - ".travis.yml"
94
109
  - CODE_OF_CONDUCT.md
95
110
  - Gemfile
@@ -97,6 +112,7 @@ files:
97
112
  - LICENSE.txt
98
113
  - README.md
99
114
  - Rakefile
115
+ - _config.yml
100
116
  - bin/console
101
117
  - bin/setup
102
118
  - lib/omniauth-instagram-graph.rb
@@ -129,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
145
  - !ruby/object:Gem::Version
130
146
  version: '0'
131
147
  requirements: []
132
- rubygems_version: 3.0.6
148
+ rubygems_version: 3.1.2
133
149
  signing_key:
134
150
  specification_version: 4
135
151
  summary: instagram Graph OAuth2 Strategy for OmniAuth