1
0
Fork 0
mirror of https://github.com/simi/omniauth-facebook.git synced 2022-11-09 12:32:45 -05:00

Upgrade Facebook Graph API to 3.0 (major gem version upgrade)

**Version 3.0**
Released May 1, 2018 | Available until July 26, 2020

https://developers.facebook.com/docs/graph-api/changelog/version3.0
This commit is contained in:
Igor Springer 2019-11-07 17:18:10 +01:00 committed by Josef Šimánek
parent 5fdcad76fb
commit 445d6d6872
5 changed files with 16 additions and 16 deletions

View file

@ -58,7 +58,7 @@ end
### API Version ### API Version
OmniAuth Facebook uses versioned API endpoints by default (current v2.11). 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): OmniAuth Facebook uses versioned API endpoints by default (current v3.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 v3.0 (assuming that exists):
```ruby ```ruby
use OmniAuth::Builder do use OmniAuth::Builder do

View file

@ -28,7 +28,7 @@ get '/client-side' do
window.fbAsyncInit = function() { window.fbAsyncInit = function() {
FB.init({ FB.init({
appId: '#{ENV['FACEBOOK_APP_ID']}', appId: '#{ENV['FACEBOOK_APP_ID']}',
version: 'v2.11', version: 'v3.0',
cookie: true // IMPORTANT must enable cookies to allow the server to access the session cookie: true // IMPORTANT must enable cookies to allow the server to access the session
}); });
console.log("fb init"); console.log("fb init");

View file

@ -1,5 +1,5 @@
module OmniAuth module OmniAuth
module Facebook module Facebook
VERSION = '5.0.0' VERSION = '6.0.0'
end end
end end

View file

@ -12,8 +12,8 @@ module OmniAuth
DEFAULT_SCOPE = 'email' DEFAULT_SCOPE = 'email'
option :client_options, { option :client_options, {
site: 'https://graph.facebook.com/v2.11', site: 'https://graph.facebook.com/v3.0',
authorize_url: "https://www.facebook.com/v2.11/dialog/oauth", authorize_url: "https://www.facebook.com/v3.0/dialog/oauth",
token_url: 'oauth/access_token' token_url: 'oauth/access_token'
} }

View file

@ -9,11 +9,11 @@ end
class ClientTest < StrategyTestCase class ClientTest < StrategyTestCase
test 'has correct Facebook site' do test 'has correct Facebook site' do
assert_equal 'https://graph.facebook.com/v2.11', strategy.client.site assert_equal 'https://graph.facebook.com/v3.0', strategy.client.site
end end
test 'has correct authorize url' do test 'has correct authorize url' do
assert_equal 'https://www.facebook.com/v2.11/dialog/oauth', strategy.client.options[:authorize_url] assert_equal 'https://www.facebook.com/v3.0/dialog/oauth', strategy.client.options[:authorize_url]
end end
test 'has correct token url with versioning' do test 'has correct token url with versioning' do
@ -99,7 +99,7 @@ class InfoTest < StrategyTestCase
@options = { secure_image_url: true } @options = { secure_image_url: true }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' } raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info) strategy.stubs(:raw_info).returns(raw_info)
assert_equal 'https://graph.facebook.com/v2.11/321/picture', strategy.info['image'] assert_equal 'https://graph.facebook.com/v3.0/321/picture', strategy.info['image']
end end
test 'returns the image_url based of the client site' do test 'returns the image_url based of the client site' do
@ -113,14 +113,14 @@ class InfoTest < StrategyTestCase
@options = { image_size: 'normal' } @options = { image_size: 'normal' }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' } raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info) strategy.stubs(:raw_info).returns(raw_info)
assert_equal 'http://graph.facebook.com/v2.11/321/picture?type=normal', strategy.info['image'] assert_equal 'http://graph.facebook.com/v3.0/321/picture?type=normal', strategy.info['image']
end end
test 'returns the image with size specified as a symbol in the `image_size` option' do test 'returns the image with size specified as a symbol in the `image_size` option' do
@options = { image_size: :normal } @options = { image_size: :normal }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' } raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info) strategy.stubs(:raw_info).returns(raw_info)
assert_equal 'http://graph.facebook.com/v2.11/321/picture?type=normal', strategy.info['image'] assert_equal 'http://graph.facebook.com/v3.0/321/picture?type=normal', strategy.info['image']
end end
test 'returns the image with width and height specified in the `image_size` option' do test 'returns the image with width and height specified in the `image_size` option' do
@ -129,7 +129,7 @@ class InfoTest < StrategyTestCase
strategy.stubs(:raw_info).returns(raw_info) strategy.stubs(:raw_info).returns(raw_info)
assert_match 'width=123', strategy.info['image'] assert_match 'width=123', strategy.info['image']
assert_match 'height=987', strategy.info['image'] assert_match 'height=987', strategy.info['image']
assert_match 'http://graph.facebook.com/v2.11/321/picture?', strategy.info['image'] assert_match 'http://graph.facebook.com/v3.0/321/picture?', strategy.info['image']
end end
end end
@ -176,7 +176,7 @@ class InfoTestOptionalDataPresent < StrategyTestCase
test 'returns the facebook avatar url' do test 'returns the facebook avatar url' do
@raw_info['id'] = '321' @raw_info['id'] = '321'
assert_equal 'http://graph.facebook.com/v2.11/321/picture', strategy.info['image'] assert_equal 'http://graph.facebook.com/v3.0/321/picture', strategy.info['image']
end end
test 'returns the Facebook link as the Facebook url' do test 'returns the Facebook link as the Facebook url' do
@ -258,7 +258,7 @@ class RawInfoTest < StrategyTestCase
@options = {appsecret_proof: @appsecret_proof, fields: 'name,email'} @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'}
end end
test 'performs a GET to https://graph.facebook.com/v2.11/me' do test 'performs a GET to https://graph.facebook.com/v3.0/me' do
strategy.stubs(:appsecret_proof).returns(@appsecret_proof) strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:access_token).returns(@access_token)
params = {params: @options} params = {params: @options}
@ -266,7 +266,7 @@ class RawInfoTest < StrategyTestCase
strategy.raw_info strategy.raw_info
end end
test 'performs a GET to https://graph.facebook.com/v2.11/me with locale' do test 'performs a GET to https://graph.facebook.com/v3.0/me with locale' do
@options.merge!({ locale: 'cs_CZ' }) @options.merge!({ locale: 'cs_CZ' })
strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof) strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
@ -275,7 +275,7 @@ class RawInfoTest < StrategyTestCase
strategy.raw_info strategy.raw_info
end end
test 'performs a GET to https://graph.facebook.com/v2.11/me with info_fields' do test 'performs a GET to https://graph.facebook.com/v3.0/me with info_fields' do
@options.merge!({info_fields: 'about'}) @options.merge!({info_fields: 'about'})
strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof) strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
@ -284,7 +284,7 @@ class RawInfoTest < StrategyTestCase
strategy.raw_info strategy.raw_info
end end
test 'performs a GET to https://graph.facebook.com/v2.11/me with default info_fields' do test 'performs a GET to https://graph.facebook.com/v3.0/me with default info_fields' do
strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof) strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}} params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}}