diff --git a/CHANGELOG.md b/CHANGELOG.md index 27641d6..477e35d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 7.0.0 (2020-08-03) + +Changes: + + - bumped version of FB Graph API to v4.0 + ## 6.0.0 (2020-01-27) Changes: diff --git a/README.md b/README.md index 801482e..91576cd 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,14 @@ end ### API Version -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 v4.0 (assuming that exists): +OmniAuth Facebook uses versioned API endpoints by default (current v4.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 v7.0 (assuming that exists): ```ruby use OmniAuth::Builder do provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], client_options: { - site: 'https://graph.facebook.com/v4.0', - authorize_url: "https://www.facebook.com/v4.0/dialog/oauth" + site: 'https://graph.facebook.com/v7.0', + authorize_url: "https://www.facebook.com/v7.0/dialog/oauth" } end ``` diff --git a/example/app.rb b/example/app.rb index 85ab0a8..a94f8a1 100644 --- a/example/app.rb +++ b/example/app.rb @@ -29,7 +29,7 @@ window.fbAsyncInit = function() { FB.init({ appId: '#{ENV['FACEBOOK_APP_ID']}', - version: 'v3.0', + version: 'v4.0', cookie: true // IMPORTANT must enable cookies to allow the server to access the session }); console.log("fb init"); diff --git a/lib/omniauth/facebook/version.rb b/lib/omniauth/facebook/version.rb index 85289de..44552bf 100644 --- a/lib/omniauth/facebook/version.rb +++ b/lib/omniauth/facebook/version.rb @@ -1,5 +1,5 @@ module OmniAuth module Facebook - VERSION = '6.0.0' + VERSION = '7.0.0' end end diff --git a/lib/omniauth/strategies/facebook.rb b/lib/omniauth/strategies/facebook.rb index dc5a18a..b54a216 100644 --- a/lib/omniauth/strategies/facebook.rb +++ b/lib/omniauth/strategies/facebook.rb @@ -12,8 +12,8 @@ class NoAuthorizationCodeError < StandardError; end DEFAULT_SCOPE = 'email' option :client_options, { - site: 'https://graph.facebook.com/v3.0', - authorize_url: "https://www.facebook.com/v3.0/dialog/oauth", + site: 'https://graph.facebook.com/v4.0', + authorize_url: "https://www.facebook.com/v4.0/dialog/oauth", token_url: 'oauth/access_token' } diff --git a/test/strategy_test.rb b/test/strategy_test.rb index ccd21fb..ecd63e3 100644 --- a/test/strategy_test.rb +++ b/test/strategy_test.rb @@ -9,11 +9,11 @@ class StrategyTest < StrategyTestCase class ClientTest < StrategyTestCase test 'has correct Facebook site' do - assert_equal 'https://graph.facebook.com/v3.0', strategy.client.site + assert_equal 'https://graph.facebook.com/v4.0', strategy.client.site end test 'has correct authorize url' do - assert_equal 'https://www.facebook.com/v3.0/dialog/oauth', strategy.client.options[:authorize_url] + assert_equal 'https://www.facebook.com/v4.0/dialog/oauth', strategy.client.options[:authorize_url] end test 'has correct token url with versioning' do @@ -99,7 +99,7 @@ class InfoTest < StrategyTestCase @options = { secure_image_url: true } raw_info = { 'name' => 'Fred Smith', 'id' => '321' } strategy.stubs(:raw_info).returns(raw_info) - assert_equal 'https://graph.facebook.com/v3.0/321/picture', strategy.info['image'] + assert_equal 'https://graph.facebook.com/v4.0/321/picture', strategy.info['image'] end test 'returns the image_url based of the client site' do @@ -113,14 +113,14 @@ class InfoTest < StrategyTestCase @options = { image_size: 'normal' } raw_info = { 'name' => 'Fred Smith', 'id' => '321' } strategy.stubs(:raw_info).returns(raw_info) - assert_equal 'http://graph.facebook.com/v3.0/321/picture?type=normal', strategy.info['image'] + assert_equal 'http://graph.facebook.com/v4.0/321/picture?type=normal', strategy.info['image'] end test 'returns the image with size specified as a symbol in the `image_size` option' do @options = { image_size: :normal } raw_info = { 'name' => 'Fred Smith', 'id' => '321' } strategy.stubs(:raw_info).returns(raw_info) - assert_equal 'http://graph.facebook.com/v3.0/321/picture?type=normal', strategy.info['image'] + assert_equal 'http://graph.facebook.com/v4.0/321/picture?type=normal', strategy.info['image'] end 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) assert_match 'width=123', strategy.info['image'] assert_match 'height=987', strategy.info['image'] - assert_match 'http://graph.facebook.com/v3.0/321/picture?', strategy.info['image'] + assert_match 'http://graph.facebook.com/v4.0/321/picture?', strategy.info['image'] end end @@ -176,7 +176,7 @@ def setup test 'returns the facebook avatar url' do @raw_info['id'] = '321' - assert_equal 'http://graph.facebook.com/v3.0/321/picture', strategy.info['image'] + assert_equal 'http://graph.facebook.com/v4.0/321/picture', strategy.info['image'] end test 'returns the Facebook link as the Facebook url' do @@ -258,7 +258,7 @@ def setup @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'} end - test 'performs a GET to https://graph.facebook.com/v3.0/me' do + test 'performs a GET to https://graph.facebook.com/v4.0/me' do strategy.stubs(:appsecret_proof).returns(@appsecret_proof) strategy.stubs(:access_token).returns(@access_token) params = {params: @options} @@ -266,7 +266,7 @@ def setup strategy.raw_info end - test 'performs a GET to https://graph.facebook.com/v3.0/me with locale' do + test 'performs a GET to https://graph.facebook.com/v4.0/me with locale' do @options.merge!({ locale: 'cs_CZ' }) strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:appsecret_proof).returns(@appsecret_proof) @@ -275,7 +275,7 @@ def setup strategy.raw_info end - test 'performs a GET to https://graph.facebook.com/v3.0/me with info_fields' do + test 'performs a GET to https://graph.facebook.com/v4.0/me with info_fields' do @options.merge!({info_fields: 'about'}) strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:appsecret_proof).returns(@appsecret_proof) @@ -284,7 +284,7 @@ def setup strategy.raw_info end - test 'performs a GET to https://graph.facebook.com/v3.0/me with default info_fields' do + test 'performs a GET to https://graph.facebook.com/v4.0/me with default info_fields' do strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:appsecret_proof).returns(@appsecret_proof) params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}}