From 6993244901a2bd458e5e4528f14572a9a92eeb71 Mon Sep 17 00:00:00 2001 From: blueplanet Date: Sun, 12 Jul 2015 20:12:24 +0900 Subject: [PATCH 1/2] Fix default info_fields to 'email' --- lib/omniauth/strategies/facebook.rb | 2 +- test/strategy_test.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/omniauth/strategies/facebook.rb b/lib/omniauth/strategies/facebook.rb index b078eb3..414173b 100644 --- a/lib/omniauth/strategies/facebook.rb +++ b/lib/omniauth/strategies/facebook.rb @@ -60,7 +60,7 @@ def raw_info def info_options params = {:appsecret_proof => appsecret_proof} - params.merge!({:fields => options[:info_fields]}) if options[:info_fields] + params.merge!({:fields => (options[:info_fields] || 'name,email')}) params.merge!({:locale => options[:locale]}) if options[:locale] { :params => params } diff --git a/test/strategy_test.rb b/test/strategy_test.rb index 3a97803..598fda7 100644 --- a/test/strategy_test.rb +++ b/test/strategy_test.rb @@ -259,7 +259,7 @@ def setup super @access_token = stub('OAuth2::AccessToken') @appsecret_proof = 'appsecret_proof' - @options = {:appsecret_proof => @appsecret_proof} + @options = {:appsecret_proof => @appsecret_proof, :fields => 'name,email'} end test 'performs a GET to https://graph.facebook.com/me' do @@ -288,6 +288,14 @@ def setup strategy.raw_info end + test 'performs a GET to https://graph.facebook.com/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'}} + @access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response')) + strategy.raw_info + end + test 'returns a Hash' do strategy.stubs(:access_token).returns(@access_token) strategy.stubs(:appsecret_proof).returns(@appsecret_proof) From 0b4814263412c2b1897e08eb6d776dc5268cf3cd Mon Sep 17 00:00:00 2001 From: blueplanet Date: Sat, 18 Jul 2015 13:39:45 +0900 Subject: [PATCH 2/2] Change README and CHANGELOG --- CHANGELOG.md | 1 + README.md | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be94f51..50a5db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2.1.0 (unreleased) - Signed request parsing extracted to `OmniAuth::Facebook::SignedRequest` class. (#183, @simi, @Vrael) + - Change default value of `info_fields` to `name,email` for the [graph-api-v2.4](https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/). ([#209](https://github.com/mkdynamic/omniauth-facebook/pull/209)) ## 2.0.1 (2015-02-21) diff --git a/README.md b/README.md index f6814b3..b524e19 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ More details [here](https://github.com/mkdynamic/omniauth-facebook/wiki/CSRF-vul --- -# OmniAuth Facebook  [![Build Status](https://secure.travis-ci.org/mkdynamic/omniauth-facebook.svg?branch=master)](https://travis-ci.org/mkdynamic/omniauth-facebook) [![Gem Version](https://img.shields.io/gem/v/omniauth-facebook.svg)](https://rubygems.org/gems/omniauth-facebook) +# OmniAuth Facebook  [![Build Status](https://secure.travis-ci.org/mkdynamic/omniauth-facebook.svg?branch=master)](https://travis-ci.org/mkdynamic/omniauth-facebook) [![Gem Version](https://img.shields.io/gem/v/omniauth-facebook.svg)](https://rubygems.org/gems/omniauth-facebook) **These notes are based on master, please see tags for README pertaining to specific releases.** @@ -45,7 +45,7 @@ Option name | Default | Explanation `scope` | `email` | A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: https://developers.facebook.com/docs/reference/login/ `display` | `page` | The display context to show the authentication page. Options are: `page`, `popup` and `touch`. Read the Facebook docs for more details: https://developers.facebook.com/docs/reference/dialogs/oauth/ `image_size` | `square` | Set the size for the returned image url in the auth hash. Valid options include `square` (50x50), `small` (50 pixels wide, variable height), `normal` (100 pixels wide, variable height), or `large` (about 200 pixels wide, variable height). Additionally, you can request a picture of a specific size by setting this option to a hash with `:width` and `:height` as keys. This will return an available profile picture closest to the requested size and requested aspect ratio. If only `:width` or `:height` is specified, we will return a picture whose width or height is closest to the requested size, respectively. -`info_fields` | | Specify exactly which fields should be returned when getting the user's info. Value should be a comma-separated string as per https://developers.facebook.com/docs/graph-api/reference/user/ (only `/me` endpoint). +`info_fields` | 'name,email' | Specify exactly which fields should be returned when getting the user's info. Value should be a comma-separated string as per https://developers.facebook.com/docs/graph-api/reference/user/ (only `/me` endpoint). `locale` | | Specify locale which should be used when getting the user's info. Value should be locale string as per https://developers.facebook.com/docs/reference/api/locale/. `auth_type` | | Optionally specifies the requested authentication features as a comma-separated list, as per https://developers.facebook.com/docs/facebook-login/reauthentication/. Valid values are `https` (checks for the presence of the secure cookie and asks for re-authentication if it is not present), and `reauthenticate` (asks the user to re-authenticate unconditionally). Use 'rerequest' when you want to request premissions. Default is `nil`. `secure_image_url` | `false` | Set to `true` to use https for the avatar image url returned in the auth hash. @@ -179,4 +179,3 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mkdynamic/omniauth-facebook/trend.png)](https://bitdeli.com/free "Bitdeli Badge") -