omniauth-instagram 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9bf0c06d40769ec45532ee39c410951683c1fad
4
- data.tar.gz: 5c179d33d74d2c739db55cb2002cc73e35a20b48
3
+ metadata.gz: 66c58d6d5a04adbdfc0ddb85432626ed42bef9e1
4
+ data.tar.gz: 9913d1a1aac2d851bd08be2c713e6de990aa1675
5
5
  SHA512:
6
- metadata.gz: 9615c813649177d15d1abe5547bcc69c5fe25ce0497d915f76ffe0d99fedec09be2b2d758b25767affa4c9b4e529dff9ba6fe076b88af8e496914e013b216555
7
- data.tar.gz: bd2d9819e0a00efadb09feeef76100e8a9cb6bb150f89ac0cf153812df8873490f6af7968dde4809f5cb29f295bb59e191fe8597158ee9e959d6b12861b7d347
6
+ metadata.gz: 227e92fcf91d58145fad7a87b2f8d95f51f87e46da4596de47f178233e60bf3dfd9ed6476018a71681fc60ae0ff9aced046e0ef4305630758584076dbe411db6
7
+ data.tar.gz: c1d5b0cf0e0a69f80f96f34f4367b329f412376aaa7c753dff68801b5810ba0614848d4caf9635bbc60abe8a3a0b512e73fc66ad3775b87069fd38fcc42b5382
data/README.md CHANGED
@@ -10,6 +10,8 @@ on the [Instagram Developer website](http://instagram.com/developer/).
10
10
  provider :instagram, ENV['INSTAGRAM_ID'], ENV['INSTAGRAM_SECRET']
11
11
  end
12
12
 
13
+ P.S: Instagram has started enforcing signed requests for its API. If you have enabled `Enforce signed requests` in your app then, you can pass `enforce_signed_requests: true` in the above configuration. More info: https://instagram.com/developer/secure-api-requests/
14
+
13
15
  ## License
14
16
 
15
17
  Copyright (c) 2011 Mihai Anca and Intridea, Inc.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Instagram
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -9,9 +9,15 @@ module OmniAuth
9
9
  :token_url => 'https://api.instagram.com/oauth/access_token'
10
10
  }
11
11
 
12
+ def callback_url
13
+ full_host + script_name + callback_path
14
+ end
15
+
12
16
  def request_phase
13
17
  options[:scope] ||= 'basic'
14
18
  options[:response_type] ||= 'code'
19
+ options[:enforce_signed_requests] ||= false
20
+ options[:extra_data] ||= false
15
21
  super
16
22
  end
17
23
 
@@ -21,21 +27,59 @@ module OmniAuth
21
27
  {
22
28
  'nickname' => raw_info['username'],
23
29
  'name' => raw_info['full_name'],
30
+ 'email' => raw_info['email'],
24
31
  'image' => raw_info['profile_picture'],
25
32
  'bio' => raw_info['bio'],
26
33
  'website' => raw_info['website'],
27
34
  }
28
35
  end
29
36
 
37
+ extra do
38
+ hash = {}
39
+ hash['raw_info'] = raw_info
40
+ hash
41
+ end
42
+
30
43
  def raw_info
31
- @data ||= access_token.params["user"]
32
- unless @data
44
+ if options[:extra_data]
45
+ endpoint = "/users/self"
46
+ params = {}
33
47
  access_token.options[:mode] = :query
34
48
  access_token.options[:param_name] = "access_token"
35
- @data ||= access_token.get('/v1/users/self').parsed['data'] || {}
49
+ params["sig"] = generate_sig(endpoint, {"access_token" => access_token.token}) if options[:enforce_signed_requests]
50
+ @data ||= access_token.get("/v1#{endpoint}", { params: params }).parsed['data'] || {}
51
+ else
52
+ @data ||= access_token.params["user"]
36
53
  end
37
54
  @data
38
55
  end
56
+
57
+ # You can pass +scope+ params to the auth request, if you need to set them dynamically.
58
+ # You can also set these options in the OmniAuth config :authorize_params option.
59
+ #
60
+ # For example: /auth/instagram?scope=likes+photos
61
+ def authorize_params
62
+ super.tap do |params|
63
+ %w[scope].each do |v|
64
+ params[v.to_sym] = request.params[v] if request.params[v]
65
+ if params[v.to_sym]
66
+ params[v.to_sym] = Array(params[v.to_sym]).join(' ')
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ def generate_sig(endpoint, params)
73
+ require 'openssl'
74
+ require 'base64'
75
+ sig = endpoint
76
+ secret = options[:client_secret]
77
+ params.sort.map do |key, val|
78
+ sig += '|%s=%s' % [key, val]
79
+ end
80
+ digest = OpenSSL::Digest.new('sha256')
81
+ return OpenSSL::HMAC.hexdigest(digest, secret, sig)
82
+ end
39
83
  end
40
84
  end
41
85
  end
@@ -15,8 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = OmniAuth::Instagram::VERSION
17
17
 
18
- gem.add_dependency 'omniauth', '~> 1.0'
19
- gem.add_dependency 'omniauth-oauth2', '~> 1.0'
18
+ gem.add_dependency 'omniauth', '~> 1'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1'
20
20
  gem.add_development_dependency 'rspec', '~> 2.12'
21
21
  gem.add_development_dependency 'rack-test'
22
22
  gem.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-instagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mihai Anca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-18 00:00:00.000000000 Z
11
+ date: 2015-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: OmniAuth strategy for Instagram.
@@ -101,7 +101,7 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
104
+ - ".gitignore"
105
105
  - Gemfile
106
106
  - README.md
107
107
  - Rakefile
@@ -120,17 +120,17 @@ require_paths:
120
120
  - lib
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - '>='
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.0.2
133
+ rubygems_version: 2.4.5.1
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: OmniAuth strategy for Instagram.