Package list ruby-omniauth-facebook / be53b7a
Bumped version of Graph API to 2.10 Piotr Jaworski authored 4 years ago Josef Šimánek committed 4 years ago
6 changed file(s) with 22 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
0 ## 4.0.1 (2018-03-14)
1
2 Changes:
3
4 - bumped version of FB Graph API to v2.10
5
06 ## 4.0.0 (2016-07-26)
17
28 Changes:
5757
5858 ### API Version
5959
60 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):
6161
6262 ```ruby
6363 use OmniAuth::Builder do
2727 window.fbAsyncInit = function() {
2828 FB.init({
2929 appId: '#{ENV['APP_ID']}',
30 version: 'v2.6',
30 version: 'v2.10',
3131 cookie: true // IMPORTANT must enable cookies to allow the server to access the session
3232 });
3333 console.log("fb init");
00 module OmniAuth
11 module Facebook
2 VERSION = "4.0.0"
2 VERSION = "4.0.1"
33 end
44 end
1111 DEFAULT_SCOPE = 'email'
1212
1313 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",
1616 token_url: 'oauth/access_token'
1717 }
1818
88
99 class ClientTest < StrategyTestCase
1010 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
1212 end
1313
1414 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]
1616 end
1717
1818 test 'has correct token url with versioning' do
9898 @options = { secure_image_url: true }
9999 raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
100100 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']
102102 end
103103
104104 test 'returns the image_url based of the client site' do
112112 @options = { image_size: 'normal' }
113113 raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
114114 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']
116116 end
117117
118118 test 'returns the image with size specified as a symbol in the `image_size` option' do
119119 @options = { image_size: :normal }
120120 raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
121121 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']
123123 end
124124
125125 test 'returns the image with width and height specified in the `image_size` option' do
128128 strategy.stubs(:raw_info).returns(raw_info)
129129 assert_match 'width=123', strategy.info['image']
130130 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']
132132 end
133133 end
134134
175175
176176 test 'returns the facebook avatar url' do
177177 @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']
179179 end
180180
181181 test 'returns the Facebook link as the Facebook url' do
257257 @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'}
258258 end
259259
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
261261 strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
262262 strategy.stubs(:access_token).returns(@access_token)
263263 params = {params: @options}
265265 strategy.raw_info
266266 end
267267
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
269269 @options.merge!({ locale: 'cs_CZ' })
270270 strategy.stubs(:access_token).returns(@access_token)
271271 strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
274274 strategy.raw_info
275275 end
276276
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
278278 @options.merge!({info_fields: 'about'})
279279 strategy.stubs(:access_token).returns(@access_token)
280280 strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
283283 strategy.raw_info
284284 end
285285
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
287287 strategy.stubs(:access_token).returns(@access_token)
288288 strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
289289 params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}}