Import upstream version 5.0.0+git20191017.2de8e13, md5 bd45ca04c2920a17e57ffd3e05944fd1
Debian Janitor
3 years ago
3 | 3 | - gem update --system |
4 | 4 | - gem --version |
5 | 5 | rvm: |
6 | - 2.3.0 | |
7 | - 2.2 | |
8 | - 2.1 | |
9 | - 2.0 | |
10 | - 1.9.3 | |
11 | - jruby-19mode | |
12 | - rbx-2 | |
6 | - 2.6 | |
7 | - 2.5 | |
8 | - 2.4 | |
9 | - 2.3 |
0 | ## 5.0.0 (2018-03-29) | |
1 | ||
2 | Changes: | |
3 | ||
4 | - bumped version of FB Graph API to v2.10 (#297, @piotrjaworski) | |
5 | - use only CRuby 2.0+ on CI (#298, @simi) | |
6 | ||
0 | 7 | ## 4.0.0 (2016-07-26) |
1 | 8 | |
2 | 9 | Changes: |
5 | 12 | - switch to versioned FB APIs, currently using v2.6 (#245, @printercu, @mkdynamic) |
6 | 13 | - remove deprecated :nickname field from README example (#223, @abelorian) |
7 | 14 | - add Ruby 2.2 + 2.3.0 to CI (#225, @tricknotes, @mkdynamic, @anoraak) |
8 | - update example app (@mkynamic) | |
15 | - update example app (@mkdynamic) | |
9 | 16 | |
10 | 17 | ## 3.0.0 (2015-10-26) |
11 | 18 |
1 | 1 | |
2 | 2 | gemspec |
3 | 3 | |
4 | gem 'rack', RUBY_VERSION < '2.2.2' ? '~> 1.6' : '>= 2.0' | |
5 | ||
4 | 6 | platforms :rbx do |
5 | 7 | gem 'rubysl', '~> 2.0' |
6 | 8 | end |
0 | 0 | # OmniAuth Facebook [](https://travis-ci.org/mkdynamic/omniauth-facebook) [](https://rubygems.org/gems/omniauth-facebook) |
1 | ||
2 | 📣 **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! 📣 | |
1 | 3 | |
2 | 4 | **These notes are based on master, please see tags for README pertaining to specific releases.** |
3 | 5 | |
23 | 25 | |
24 | 26 | ```ruby |
25 | 27 | Rails.application.config.middleware.use OmniAuth::Builder do |
26 | provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'] | |
28 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'] | |
27 | 29 | end |
28 | 30 | ``` |
29 | 31 | |
48 | 50 | |
49 | 51 | ```ruby |
50 | 52 | Rails.application.config.middleware.use OmniAuth::Builder do |
51 | provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], | |
53 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], | |
52 | 54 | scope: 'email,user_birthday,read_stream', display: 'popup' |
53 | 55 | end |
54 | 56 | ``` |
55 | 57 | |
56 | 58 | ### API Version |
57 | 59 | |
58 | OmniAuth Facebook uses versioned API endpoints by default (current v2.6). 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 v3.0 (assuming that exists): | |
60 | OmniAuth Facebook uses versioned API endpoints by default (current v2.10). 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 v3.0 (assuming that exists): | |
59 | 61 | |
60 | 62 | ```ruby |
61 | 63 | use OmniAuth::Builder do |
62 | provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], | |
64 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], | |
63 | 65 | client_options: { |
64 | 66 | site: 'https://graph.facebook.com/v3.0', |
65 | 67 | authorize_url: "https://www.facebook.com/v3.0/dialog/oauth" |
85 | 87 | first_name: 'Joe', |
86 | 88 | last_name: 'Bloggs', |
87 | 89 | image: 'http://graph.facebook.com/1234567/picture?type=square', |
88 | urls: { Facebook: 'http://www.facebook.com/jbloggs' }, | |
89 | location: 'Palo Alto, California', | |
90 | 90 | verified: true |
91 | 91 | }, |
92 | 92 | credentials: { |
151 | 151 | |
152 | 152 | ## Supported Rubies |
153 | 153 | |
154 | - Ruby MRI (1.9.3+) | |
155 | - JRuby (1.9 mode) | |
156 | - RBX (2.1.1+) | |
154 | - Ruby MRI (2.3, 2.4, 2.5, 2.6) | |
157 | 155 | |
158 | 156 | ## License |
159 | 157 |
26 | 26 | <script type="text/javascript"> |
27 | 27 | window.fbAsyncInit = function() { |
28 | 28 | FB.init({ |
29 | appId: '#{ENV['APP_ID']}', | |
30 | version: 'v2.6', | |
29 | appId: '#{ENV['FACEBOOK_APP_ID']}', | |
30 | version: 'v2.10', | |
31 | 31 | cookie: true // IMPORTANT must enable cookies to allow the server to access the session |
32 | 32 | }); |
33 | 33 | console.log("fb init"); |
4 | 4 | use Rack::Session::Cookie, secret: 'abc123' |
5 | 5 | |
6 | 6 | use OmniAuth::Builder do |
7 | provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'] | |
7 | provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'] | |
8 | 8 | end |
9 | 9 | |
10 | 10 | run Sinatra::Application |
11 | 11 | DEFAULT_SCOPE = 'email' |
12 | 12 | |
13 | 13 | option :client_options, { |
14 | site: 'https://graph.facebook.com/v2.6', | |
15 | authorize_url: "https://www.facebook.com/v2.6/dialog/oauth", | |
14 | site: 'https://graph.facebook.com/v2.10', | |
15 | authorize_url: "https://www.facebook.com/v2.10/dialog/oauth", | |
16 | 16 | token_url: 'oauth/access_token' |
17 | 17 | } |
18 | 18 |
8 | 8 | |
9 | 9 | class ClientTest < StrategyTestCase |
10 | 10 | test 'has correct Facebook site' do |
11 | assert_equal 'https://graph.facebook.com/v2.6', strategy.client.site | |
11 | assert_equal 'https://graph.facebook.com/v2.10', strategy.client.site | |
12 | 12 | end |
13 | 13 | |
14 | 14 | test 'has correct authorize url' do |
15 | assert_equal 'https://www.facebook.com/v2.6/dialog/oauth', strategy.client.options[:authorize_url] | |
15 | assert_equal 'https://www.facebook.com/v2.10/dialog/oauth', strategy.client.options[:authorize_url] | |
16 | 16 | end |
17 | 17 | |
18 | 18 | test 'has correct token url with versioning' do |
98 | 98 | @options = { secure_image_url: true } |
99 | 99 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
100 | 100 | strategy.stubs(:raw_info).returns(raw_info) |
101 | assert_equal 'https://graph.facebook.com/v2.6/321/picture', strategy.info['image'] | |
101 | assert_equal 'https://graph.facebook.com/v2.10/321/picture', strategy.info['image'] | |
102 | 102 | end |
103 | 103 | |
104 | 104 | test 'returns the image_url based of the client site' do |
112 | 112 | @options = { image_size: 'normal' } |
113 | 113 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
114 | 114 | strategy.stubs(:raw_info).returns(raw_info) |
115 | assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image'] | |
115 | assert_equal 'http://graph.facebook.com/v2.10/321/picture?type=normal', strategy.info['image'] | |
116 | 116 | end |
117 | 117 | |
118 | 118 | test 'returns the image with size specified as a symbol in the `image_size` option' do |
119 | 119 | @options = { image_size: :normal } |
120 | 120 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
121 | 121 | strategy.stubs(:raw_info).returns(raw_info) |
122 | assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image'] | |
122 | assert_equal 'http://graph.facebook.com/v2.10/321/picture?type=normal', strategy.info['image'] | |
123 | 123 | end |
124 | 124 | |
125 | 125 | test 'returns the image with width and height specified in the `image_size` option' do |
128 | 128 | strategy.stubs(:raw_info).returns(raw_info) |
129 | 129 | assert_match 'width=123', strategy.info['image'] |
130 | 130 | assert_match 'height=987', strategy.info['image'] |
131 | assert_match 'http://graph.facebook.com/v2.6/321/picture?', strategy.info['image'] | |
131 | assert_match 'http://graph.facebook.com/v2.10/321/picture?', strategy.info['image'] | |
132 | 132 | end |
133 | 133 | end |
134 | 134 | |
175 | 175 | |
176 | 176 | test 'returns the facebook avatar url' do |
177 | 177 | @raw_info['id'] = '321' |
178 | assert_equal 'http://graph.facebook.com/v2.6/321/picture', strategy.info['image'] | |
178 | assert_equal 'http://graph.facebook.com/v2.10/321/picture', strategy.info['image'] | |
179 | 179 | end |
180 | 180 | |
181 | 181 | test 'returns the Facebook link as the Facebook url' do |
257 | 257 | @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'} |
258 | 258 | end |
259 | 259 | |
260 | test 'performs a GET to https://graph.facebook.com/v2.6/me' do | |
260 | test 'performs a GET to https://graph.facebook.com/v2.10/me' do | |
261 | 261 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
262 | 262 | strategy.stubs(:access_token).returns(@access_token) |
263 | 263 | params = {params: @options} |
265 | 265 | strategy.raw_info |
266 | 266 | end |
267 | 267 | |
268 | test 'performs a GET to https://graph.facebook.com/v2.6/me with locale' do | |
268 | test 'performs a GET to https://graph.facebook.com/v2.10/me with locale' do | |
269 | 269 | @options.merge!({ locale: 'cs_CZ' }) |
270 | 270 | strategy.stubs(:access_token).returns(@access_token) |
271 | 271 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
274 | 274 | strategy.raw_info |
275 | 275 | end |
276 | 276 | |
277 | test 'performs a GET to https://graph.facebook.com/v2.6/me with info_fields' do | |
277 | test 'performs a GET to https://graph.facebook.com/v2.10/me with info_fields' do | |
278 | 278 | @options.merge!({info_fields: 'about'}) |
279 | 279 | strategy.stubs(:access_token).returns(@access_token) |
280 | 280 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
283 | 283 | strategy.raw_info |
284 | 284 | end |
285 | 285 | |
286 | test 'performs a GET to https://graph.facebook.com/v2.6/me with default info_fields' do | |
286 | test 'performs a GET to https://graph.facebook.com/v2.10/me with default info_fields' do | |
287 | 287 | strategy.stubs(:access_token).returns(@access_token) |
288 | 288 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
289 | 289 | params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}} |