omniauth-facebook 10.0.0 β 11.0.0
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 +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +3 -4
- data/.github/workflows/stale.yml +2 -2
- data/CHANGELOG.md +10 -0
- data/README.md +3 -3
- data/lib/omniauth/facebook/version.rb +1 -1
- data/lib/omniauth/strategies/facebook.rb +5 -7
- data/omniauth-facebook.gemspec +1 -1
- data/test/strategy_test.rb +8 -29
- data/test/support/shared_examples.rb +5 -5
- metadata +4 -11
- data/example/Gemfile +0 -5
- data/example/Gemfile.lock +0 -63
- data/example/app.rb +0 -86
- data/example/config.ru +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84cc0553d04d99409310d315bd015cdb8ccb9d9b44a7e1ba2e4e5dc1bb0e3352
|
|
4
|
+
data.tar.gz: '0810f2c70af2a19545eb8ba78917f50fd484fd49763e7000d184d66f4775a892'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f43b2f8440b47bea9033b951ea6195abd1e2618204790830cefaf5e2b98ccb67d6c4e2678531f654e5e647738008ef8f21d25bd29837b5f4438ad4e84abd0205
|
|
7
|
+
data.tar.gz: d193ba5cb97033c62c4127f32155d5741f324adf6582e9e567c36e75b9e7eef7ec0c67b95decf37e20e97ebbfe025dcb7b5682dad11798adf7b83ec123c1998e
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -9,13 +9,12 @@ jobs:
|
|
|
9
9
|
fail-fast: false
|
|
10
10
|
matrix:
|
|
11
11
|
ruby:
|
|
12
|
-
- "3.0"
|
|
13
|
-
- "3.1"
|
|
14
|
-
- "3.2"
|
|
15
12
|
- "3.3"
|
|
13
|
+
- "3.4"
|
|
14
|
+
- "4.0"
|
|
16
15
|
- head
|
|
17
16
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
17
|
+
- uses: actions/checkout@v7
|
|
19
18
|
- name: Set up Ruby
|
|
20
19
|
uses: ruby/setup-ruby@v1
|
|
21
20
|
with:
|
data/.github/workflows/stale.yml
CHANGED
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
|
|
18
18
|
stale-issue-label: 'no-issue-activity'
|
|
19
19
|
stale-pr-label: 'no-pr-activity'
|
|
20
|
-
days-before-stale:
|
|
21
|
-
days-before-close:
|
|
20
|
+
days-before-stale: 90
|
|
21
|
+
days-before-close: 60
|
|
22
22
|
exempt-pr-label: 'pinned'
|
|
23
23
|
exempt-issue-label: 'pinned'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
## 11.0.0 (2026-07-18)
|
|
2
|
+
|
|
3
|
+
Changes:
|
|
4
|
+
|
|
5
|
+
- bumped version of FB Graph API to v24.0
|
|
6
|
+
- remove access token from profile picture URL (#388, @Rubyist007)
|
|
7
|
+
|
|
1
8
|
## 10.0.0 (2024-05-23)
|
|
2
9
|
|
|
3
10
|
Changes:
|
|
4
11
|
|
|
5
12
|
- bumped version of FB Graph API to v19.0
|
|
13
|
+
- add `config_id` to per-request options and configuration (#386, @harism2)
|
|
14
|
+
- fix duplicated `script_name` in `callback_url` (#380, @tak1n)
|
|
15
|
+
- add `bigdecimal` dependency for Ruby 3.4 compatibility
|
|
6
16
|
|
|
7
17
|
## 9.0.0 (2021-10-25)
|
|
8
18
|
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# OmniAuth Facebook [](https://github.com/simi/omniauth-facebook/actions/workflows/ci.yml) [](https://rubygems.org/gems/omniauth-facebook)
|
|
2
2
|
|
|
3
3
|
π£ **NOTICE** Weβre looking for maintainers to help keep this project up-to-date. If you are interested in helping please open an Issue expressing your interest. Thanks! π£
|
|
4
4
|
|
|
@@ -60,7 +60,7 @@ end
|
|
|
60
60
|
|
|
61
61
|
### API Version
|
|
62
62
|
|
|
63
|
-
OmniAuth Facebook uses versioned API endpoints by default (current
|
|
63
|
+
OmniAuth Facebook uses versioned API endpoints by default (current v24.0). You can configure a different version via `client_options` hash passed to `provider`, specifically you should change the version in the `site` and `authorize_url` parameters. For example, to change to v20.0 (assuming that exists):
|
|
64
64
|
|
|
65
65
|
```ruby
|
|
66
66
|
use OmniAuth::Builder do
|
|
@@ -89,7 +89,7 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
|
|
89
89
|
name: 'Joe Bloggs',
|
|
90
90
|
first_name: 'Joe',
|
|
91
91
|
last_name: 'Bloggs',
|
|
92
|
-
image: 'http://graph.facebook.com/1234567/picture?type=square
|
|
92
|
+
image: 'http://graph.facebook.com/1234567/picture?type=square',
|
|
93
93
|
verified: true
|
|
94
94
|
},
|
|
95
95
|
credentials: {
|
|
@@ -10,7 +10,7 @@ module OmniAuth
|
|
|
10
10
|
class NoAuthorizationCodeError < StandardError; end
|
|
11
11
|
|
|
12
12
|
DEFAULT_SCOPE = 'email'
|
|
13
|
-
DEFAULT_FACEBOOK_API_VERSION = '
|
|
13
|
+
DEFAULT_FACEBOOK_API_VERSION = 'v24.0'.freeze
|
|
14
14
|
|
|
15
15
|
option :client_options, {
|
|
16
16
|
site: "https://graph.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}",
|
|
@@ -164,15 +164,13 @@ module OmniAuth
|
|
|
164
164
|
uri_class = options[:secure_image_url] ? URI::HTTPS : URI::HTTP
|
|
165
165
|
site_uri = URI.parse(client.site)
|
|
166
166
|
url = uri_class.build({host: site_uri.host, path: "#{site_uri.path}/#{uid}/picture"})
|
|
167
|
-
query = { access_token: access_token.token }
|
|
168
167
|
|
|
169
|
-
if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol)
|
|
170
|
-
|
|
168
|
+
query = if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol)
|
|
169
|
+
{ type: options[:image_size] }
|
|
171
170
|
elsif options[:image_size].is_a?(Hash)
|
|
172
|
-
|
|
171
|
+
options[:image_size]
|
|
173
172
|
end
|
|
174
|
-
|
|
175
|
-
url.query = Rack::Utils.build_query(query)
|
|
173
|
+
url.query = Rack::Utils.build_query(query) if query
|
|
176
174
|
|
|
177
175
|
url.to_s
|
|
178
176
|
end
|
data/omniauth-facebook.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.homepage = 'https://github.com/simi/omniauth-facebook'
|
|
12
12
|
s.license = 'MIT'
|
|
13
13
|
|
|
14
|
-
s.files = `git ls-files`.split("\n")
|
|
14
|
+
s.files = `git ls-files`.split("\n").reject { |path| path.start_with? "example/" }
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
17
17
|
s.require_paths = ['lib']
|
data/test/strategy_test.rb
CHANGED
|
@@ -102,67 +102,54 @@ class UidTest < StrategyTestCase
|
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
class InfoTest < StrategyTestCase
|
|
105
|
-
def setup
|
|
106
|
-
super
|
|
107
|
-
@access_token = stub('OAuth2::AccessToken')
|
|
108
|
-
@access_token.stubs(:token).returns('test_access_token')
|
|
109
|
-
end
|
|
110
|
-
|
|
111
105
|
test 'returns the secure facebook avatar url when `secure_image_url` option is set to true' do
|
|
112
106
|
@options = { secure_image_url: true }
|
|
113
107
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
114
108
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
115
|
-
|
|
116
|
-
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture?access_token=test_access_token", strategy.info['image']
|
|
109
|
+
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture", strategy.info['image']
|
|
117
110
|
end
|
|
118
111
|
|
|
119
112
|
test 'returns the non-ssl facebook avatar url when `secure_image_url` option is set to false' do
|
|
120
113
|
@options = { secure_image_url: false }
|
|
121
114
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
122
115
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
123
|
-
|
|
124
|
-
assert_equal "http://graph.facebook.com/#{@facebook_api_version}/321/picture?access_token=test_access_token", strategy.info['image']
|
|
116
|
+
assert_equal "http://graph.facebook.com/#{@facebook_api_version}/321/picture", strategy.info['image']
|
|
125
117
|
end
|
|
126
118
|
|
|
127
119
|
test 'returns the secure facebook avatar url when `secure_image_url` option is omitted' do
|
|
128
120
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
129
121
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
130
|
-
|
|
131
|
-
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture?access_token=test_access_token", strategy.info['image']
|
|
122
|
+
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture", strategy.info['image']
|
|
132
123
|
end
|
|
133
124
|
|
|
134
125
|
test 'returns the image_url based of the client site' do
|
|
135
126
|
@options = { secure_image_url: true, client_options: {site: "https://blah.facebook.com/v2.2"}}
|
|
136
127
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
137
128
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
138
|
-
strategy.
|
|
139
|
-
assert_equal "https://blah.facebook.com/v2.2/321/picture?access_token=test_access_token", strategy.info['image']
|
|
129
|
+
assert_equal "https://blah.facebook.com/v2.2/321/picture", strategy.info['image']
|
|
140
130
|
end
|
|
141
131
|
|
|
142
132
|
test 'returns the image with size specified in the `image_size` option' do
|
|
143
133
|
@options = { image_size: 'normal' }
|
|
144
134
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
145
135
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
146
|
-
|
|
147
|
-
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture?access_token=test_access_token&type=normal", strategy.info['image']
|
|
136
|
+
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture?type=normal", strategy.info['image']
|
|
148
137
|
end
|
|
149
138
|
|
|
150
139
|
test 'returns the image with size specified as a symbol in the `image_size` option' do
|
|
151
140
|
@options = { image_size: :normal }
|
|
152
141
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
153
142
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
154
|
-
|
|
155
|
-
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture?access_token=test_access_token&type=normal", strategy.info['image']
|
|
143
|
+
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture?type=normal", strategy.info['image']
|
|
156
144
|
end
|
|
157
145
|
|
|
158
146
|
test 'returns the image with width and height specified in the `image_size` option' do
|
|
159
147
|
@options = { image_size: { width: 123, height: 987 } }
|
|
160
148
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
161
149
|
strategy.stubs(:raw_info).returns(raw_info)
|
|
162
|
-
strategy.stubs(:access_token).returns(@access_token)
|
|
163
150
|
assert_match 'width=123', strategy.info['image']
|
|
164
151
|
assert_match 'height=987', strategy.info['image']
|
|
165
|
-
assert_match "https://graph.facebook.com/#{@facebook_api_version}/321/picture
|
|
152
|
+
assert_match "https://graph.facebook.com/#{@facebook_api_version}/321/picture", strategy.info['image']
|
|
166
153
|
end
|
|
167
154
|
end
|
|
168
155
|
|
|
@@ -171,10 +158,6 @@ class InfoTestOptionalDataPresent < StrategyTestCase
|
|
|
171
158
|
super
|
|
172
159
|
@raw_info ||= { 'name' => 'Fred Smith' }
|
|
173
160
|
strategy.stubs(:raw_info).returns(@raw_info)
|
|
174
|
-
|
|
175
|
-
access_token = stub('OAuth2::AccessToken')
|
|
176
|
-
access_token.stubs(:token).returns('test_access_token')
|
|
177
|
-
strategy.stubs(:access_token).returns(access_token)
|
|
178
161
|
end
|
|
179
162
|
|
|
180
163
|
test 'returns the name' do
|
|
@@ -213,7 +196,7 @@ class InfoTestOptionalDataPresent < StrategyTestCase
|
|
|
213
196
|
|
|
214
197
|
test 'returns the facebook avatar url' do
|
|
215
198
|
@raw_info['id'] = '321'
|
|
216
|
-
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture
|
|
199
|
+
assert_equal "https://graph.facebook.com/#{@facebook_api_version}/321/picture", strategy.info['image']
|
|
217
200
|
end
|
|
218
201
|
|
|
219
202
|
test 'returns the Facebook link as the Facebook url' do
|
|
@@ -252,10 +235,6 @@ class InfoTestOptionalDataNotPresent < StrategyTestCase
|
|
|
252
235
|
super
|
|
253
236
|
@raw_info ||= { 'name' => 'Fred Smith' }
|
|
254
237
|
strategy.stubs(:raw_info).returns(@raw_info)
|
|
255
|
-
|
|
256
|
-
access_token = stub('OAuth2::AccessToken')
|
|
257
|
-
access_token.stubs(:token).returns('test_access_token')
|
|
258
|
-
strategy.stubs(:access_token).returns(access_token)
|
|
259
238
|
end
|
|
260
239
|
|
|
261
240
|
test 'has no email key' do
|
|
@@ -8,10 +8,10 @@ module OAuth2StrategyTests
|
|
|
8
8
|
include TokenParamsTests
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
module ClientTests
|
|
13
13
|
extend BlockTestHelper
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
test 'should be initialized with symbolized client_options' do
|
|
16
16
|
@options = { client_options: { 'authorize_url' => 'https://example.com' } }
|
|
17
17
|
assert_equal 'https://example.com', strategy.client.options[:authorize_url]
|
|
@@ -20,7 +20,7 @@ module OAuth2StrategyTests
|
|
|
20
20
|
|
|
21
21
|
module AuthorizeParamsTests
|
|
22
22
|
extend BlockTestHelper
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
test 'should include any authorize params passed in the :authorize_params option' do
|
|
25
25
|
@options = { authorize_params: { foo: 'bar', baz: 'zip' } }
|
|
26
26
|
assert_equal 'bar', strategy.authorize_params['foo']
|
|
@@ -32,7 +32,7 @@ module OAuth2StrategyTests
|
|
|
32
32
|
assert_equal 'bar', strategy.authorize_params['scope']
|
|
33
33
|
assert_equal 'baz', strategy.authorize_params['foo']
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
test 'should exclude top-level options that are not passed' do
|
|
37
37
|
@options = { authorize_options: [:bar] }
|
|
38
38
|
refute_has_key :bar, strategy.authorize_params
|
|
@@ -69,7 +69,7 @@ module OAuth2StrategyTests
|
|
|
69
69
|
|
|
70
70
|
module TokenParamsTests
|
|
71
71
|
extend BlockTestHelper
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
test 'should include any authorize params passed in the :token_params option' do
|
|
74
74
|
@options = { token_params: { foo: 'bar', baz: 'zip' } }
|
|
75
75
|
assert_equal 'bar', strategy.token_params['foo']
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-facebook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 11.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Dodwell
|
|
8
8
|
- Josef Ε imΓ‘nek
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: omniauth-oauth2
|
|
@@ -87,7 +86,6 @@ dependencies:
|
|
|
87
86
|
- - ">="
|
|
88
87
|
- !ruby/object:Gem::Version
|
|
89
88
|
version: '0'
|
|
90
|
-
description:
|
|
91
89
|
email:
|
|
92
90
|
- mark@madeofcode.com
|
|
93
91
|
- retro@ballgag.cz
|
|
@@ -95,6 +93,7 @@ executables: []
|
|
|
95
93
|
extensions: []
|
|
96
94
|
extra_rdoc_files: []
|
|
97
95
|
files:
|
|
96
|
+
- ".github/dependabot.yml"
|
|
98
97
|
- ".github/workflows/ci.yml"
|
|
99
98
|
- ".github/workflows/stale.yml"
|
|
100
99
|
- ".gitignore"
|
|
@@ -102,10 +101,6 @@ files:
|
|
|
102
101
|
- Gemfile
|
|
103
102
|
- README.md
|
|
104
103
|
- Rakefile
|
|
105
|
-
- example/Gemfile
|
|
106
|
-
- example/Gemfile.lock
|
|
107
|
-
- example/app.rb
|
|
108
|
-
- example/config.ru
|
|
109
104
|
- lib/omniauth-facebook.rb
|
|
110
105
|
- lib/omniauth/facebook.rb
|
|
111
106
|
- lib/omniauth/facebook/signed_request.rb
|
|
@@ -122,7 +117,6 @@ homepage: https://github.com/simi/omniauth-facebook
|
|
|
122
117
|
licenses:
|
|
123
118
|
- MIT
|
|
124
119
|
metadata: {}
|
|
125
|
-
post_install_message:
|
|
126
120
|
rdoc_options: []
|
|
127
121
|
require_paths:
|
|
128
122
|
- lib
|
|
@@ -137,8 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
137
131
|
- !ruby/object:Gem::Version
|
|
138
132
|
version: '0'
|
|
139
133
|
requirements: []
|
|
140
|
-
rubygems_version:
|
|
141
|
-
signing_key:
|
|
134
|
+
rubygems_version: 4.0.10
|
|
142
135
|
specification_version: 4
|
|
143
136
|
summary: Facebook OAuth2 Strategy for OmniAuth
|
|
144
137
|
test_files:
|
data/example/Gemfile
DELETED
data/example/Gemfile.lock
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ..
|
|
3
|
-
specs:
|
|
4
|
-
omniauth-facebook (8.0.0)
|
|
5
|
-
omniauth-oauth2 (~> 1.2)
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: https://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
backports (3.15.0)
|
|
11
|
-
faraday (1.1.0)
|
|
12
|
-
multipart-post (>= 1.2, < 3)
|
|
13
|
-
ruby2_keywords
|
|
14
|
-
hashie (4.1.0)
|
|
15
|
-
jwt (2.2.2)
|
|
16
|
-
multi_json (1.14.1)
|
|
17
|
-
multi_xml (0.6.0)
|
|
18
|
-
multipart-post (2.1.1)
|
|
19
|
-
mustermann (1.1.1)
|
|
20
|
-
ruby2_keywords (~> 0.0.1)
|
|
21
|
-
oauth2 (1.4.4)
|
|
22
|
-
faraday (>= 0.8, < 2.0)
|
|
23
|
-
jwt (>= 1.0, < 3.0)
|
|
24
|
-
multi_json (~> 1.3)
|
|
25
|
-
multi_xml (~> 0.5)
|
|
26
|
-
rack (>= 1.2, < 3)
|
|
27
|
-
omniauth (1.9.1)
|
|
28
|
-
hashie (>= 3.4.6)
|
|
29
|
-
rack (>= 1.6.2, < 3)
|
|
30
|
-
omniauth-oauth2 (1.7.0)
|
|
31
|
-
oauth2 (~> 1.4)
|
|
32
|
-
omniauth (~> 1.9)
|
|
33
|
-
rack (2.2.3)
|
|
34
|
-
rack-protection (2.0.8.1)
|
|
35
|
-
rack
|
|
36
|
-
ruby2_keywords (0.0.2)
|
|
37
|
-
sinatra (2.0.8.1)
|
|
38
|
-
mustermann (~> 1.0)
|
|
39
|
-
rack (~> 2.0)
|
|
40
|
-
rack-protection (= 2.0.8.1)
|
|
41
|
-
tilt (~> 2.0)
|
|
42
|
-
sinatra-contrib (2.0.8.1)
|
|
43
|
-
backports (>= 2.8.2)
|
|
44
|
-
multi_json
|
|
45
|
-
mustermann (~> 1.0)
|
|
46
|
-
rack-protection (= 2.0.8.1)
|
|
47
|
-
sinatra (= 2.0.8.1)
|
|
48
|
-
tilt (~> 2.0)
|
|
49
|
-
sinatra-reloader (1.0)
|
|
50
|
-
sinatra-contrib
|
|
51
|
-
tilt (2.0.10)
|
|
52
|
-
|
|
53
|
-
PLATFORMS
|
|
54
|
-
ruby
|
|
55
|
-
x64-mingw32
|
|
56
|
-
|
|
57
|
-
DEPENDENCIES
|
|
58
|
-
omniauth-facebook!
|
|
59
|
-
sinatra
|
|
60
|
-
sinatra-reloader
|
|
61
|
-
|
|
62
|
-
BUNDLED WITH
|
|
63
|
-
1.17.3
|
data/example/app.rb
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
require 'sinatra'
|
|
2
|
-
require "sinatra/reloader"
|
|
3
|
-
require 'yaml'
|
|
4
|
-
require 'json'
|
|
5
|
-
|
|
6
|
-
# configure sinatra
|
|
7
|
-
set :run, false
|
|
8
|
-
set :raise_errors, true
|
|
9
|
-
|
|
10
|
-
# REQUEST STEP (server-side flow)
|
|
11
|
-
get '/server-side' do
|
|
12
|
-
# NOTE: You would just hit this endpoint directly from the browser in a real app. The redirect is
|
|
13
|
-
# just here to explicit declare this server-side flow.
|
|
14
|
-
redirect '/auth/facebook'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# REQUEST STEP (client-side flow)
|
|
18
|
-
get '/client-side' do
|
|
19
|
-
content_type 'text/html'
|
|
20
|
-
# NOTE: When you enable cookie below in the FB.init call the GET request in the FB.login callback
|
|
21
|
-
# will send a signed request in a cookie back the OmniAuth callback which will parse out the
|
|
22
|
-
# authorization code and obtain an access_token with it.
|
|
23
|
-
<<-HTML
|
|
24
|
-
<html>
|
|
25
|
-
<head>
|
|
26
|
-
<title>Client-side Flow Example</title>
|
|
27
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js" type="text/javascript"></script>
|
|
28
|
-
<script type="text/javascript">
|
|
29
|
-
window.fbAsyncInit = function() {
|
|
30
|
-
FB.init({
|
|
31
|
-
appId: '#{ENV['FACEBOOK_APP_ID']}',
|
|
32
|
-
version: 'v4.0',
|
|
33
|
-
cookie: true // IMPORTANT must enable cookies to allow the server to access the session
|
|
34
|
-
});
|
|
35
|
-
console.log("fb init");
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
(function(d, s, id){
|
|
39
|
-
var js, fjs = d.getElementsByTagName(s)[0];
|
|
40
|
-
if (d.getElementById(id)) {return;}
|
|
41
|
-
js = d.createElement(s); js.id = id;
|
|
42
|
-
js.src = "//connect.facebook.net/en_US/sdk.js";
|
|
43
|
-
fjs.parentNode.insertBefore(js, fjs);
|
|
44
|
-
}(document, 'script', 'facebook-jssdk'));
|
|
45
|
-
</script>
|
|
46
|
-
</head>
|
|
47
|
-
<body>
|
|
48
|
-
<div id="fb-root"></div>
|
|
49
|
-
|
|
50
|
-
<p id="connect">
|
|
51
|
-
<a href="#">Connect to FB!</a>
|
|
52
|
-
</p>
|
|
53
|
-
|
|
54
|
-
<p id="results" />
|
|
55
|
-
|
|
56
|
-
<script type="text/javascript">
|
|
57
|
-
$('a').click(function(e) {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
|
|
60
|
-
FB.login(function(response) {
|
|
61
|
-
console.log(response);
|
|
62
|
-
if (response.authResponse) {
|
|
63
|
-
$('#connect').html('Connected! Hitting OmniAuth callback (GET /auth/facebook/callback)...');
|
|
64
|
-
|
|
65
|
-
// since we have cookies enabled, this request will allow omniauth to parse
|
|
66
|
-
// out the auth code from the signed request in the fbsr_XXX cookie
|
|
67
|
-
$.getJSON('/auth/facebook/callback', function(json) {
|
|
68
|
-
$('#connect').html('Connected! Callback complete.');
|
|
69
|
-
$('#results').html(JSON.stringify(json));
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}); // if you want custom scopes, pass them as an extra, final argument to FB.login
|
|
73
|
-
});
|
|
74
|
-
</script>
|
|
75
|
-
</body>
|
|
76
|
-
</html>
|
|
77
|
-
HTML
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# CALLBACK STEP
|
|
81
|
-
# - redirected here for server-side flow
|
|
82
|
-
# - ajax request made here for client-side flow
|
|
83
|
-
get '/auth/:provider/callback' do
|
|
84
|
-
content_type 'application/json'
|
|
85
|
-
JSON.dump(request.env)
|
|
86
|
-
end
|
data/example/config.ru
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'bundler/setup'
|
|
2
|
-
require 'omniauth-facebook'
|
|
3
|
-
require './app.rb'
|
|
4
|
-
|
|
5
|
-
use Rack::Session::Cookie, secret: 'abc123'
|
|
6
|
-
|
|
7
|
-
use OmniAuth::Builder do
|
|
8
|
-
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET']
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
run Sinatra::Application
|