Import upstream version 8.0.0
Debian Janitor
2 years ago
0 | name: Mark stale issues and pull requests | |
1 | ||
2 | on: | |
3 | schedule: | |
4 | - cron: "0 0 * * *" | |
5 | ||
6 | jobs: | |
7 | stale: | |
8 | ||
9 | runs-on: ubuntu-latest | |
10 | ||
11 | steps: | |
12 | - uses: actions/stale@v1 | |
13 | with: | |
14 | repo-token: ${{ secrets.GITHUB_TOKEN }} | |
15 | stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' | |
16 | stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' | |
17 | stale-issue-label: 'no-issue-activity' | |
18 | stale-pr-label: 'no-pr-activity' | |
19 | days-before-stale: 30 | |
20 | days-before-close: 5 | |
21 | exempt-pr-label: 'pinned' | |
22 | exempt-issue-label: 'pinned' |
0 | before_install: | |
1 | - gem update bundler | |
2 | - bundle --version | |
3 | - gem update --system | |
4 | - gem --version | |
0 | language: ruby | |
1 | cache: bundler | |
5 | 2 | rvm: |
6 | - 2.3.0 | |
7 | - 2.2 | |
8 | - 2.1 | |
9 | - 2.0 | |
10 | - 1.9.3 | |
11 | - jruby-19mode | |
12 | - rbx-2 | |
3 | - 2.7 | |
4 | - 2.6 | |
5 | - 2.5 |
0 | ## 8.0.0 (2020-10-20) | |
1 | ||
2 | Changes: | |
3 | ||
4 | - user profile picture link includes access token (#344, @anklos) | |
5 | ||
6 | ## 7.0.0 (2020-08-03) | |
7 | ||
8 | Changes: | |
9 | ||
10 | - bumped version of FB Graph API to v4.0 | |
11 | ||
12 | ## 6.0.0 (2020-01-27) | |
13 | ||
14 | Changes: | |
15 | ||
16 | - bumped version of FB Graph API to v3.0 | |
17 | ||
18 | ## 5.0.0 (2018-03-29) | |
19 | ||
20 | Changes: | |
21 | ||
22 | - bumped version of FB Graph API to v2.10 (#297, @piotrjaworski) | |
23 | - use only CRuby 2.0+ on CI (#298, @simi) | |
24 | ||
0 | 25 | ## 4.0.0 (2016-07-26) |
1 | 26 | |
2 | 27 | Changes: |
5 | 30 | - switch to versioned FB APIs, currently using v2.6 (#245, @printercu, @mkdynamic) |
6 | 31 | - remove deprecated :nickname field from README example (#223, @abelorian) |
7 | 32 | - add Ruby 2.2 + 2.3.0 to CI (#225, @tricknotes, @mkdynamic, @anoraak) |
8 | - update example app (@mkynamic) | |
33 | - update example app (@mkdynamic) | |
9 | 34 | |
10 | 35 | ## 3.0.0 (2015-10-26) |
11 | 36 |
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 | # 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) | |
0 | # OmniAuth Facebook [![Build Status](https://secure.travis-ci.org/simi/omniauth-facebook.svg?branch=master)](https://travis-ci.org/simi/omniauth-facebook) [![Gem Version](https://img.shields.io/gem/v/omniauth-facebook.svg)](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 | |
30 | [See the example Sinatra app for full examples](https://github.com/mkdynamic/omniauth-facebook/blob/master/example/config.ru) of both the server and client-side flows (including using the Facebook Javascript SDK). | |
32 | [See the example Sinatra app for full examples](https://github.com/simi/omniauth-facebook/blob/master/example/config.ru) of both the server and client-side flows (including using the Facebook Javascript SDK). | |
31 | 33 | |
32 | 34 | ## Configuring |
33 | 35 | |
38 | 40 | `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/ |
39 | 41 | `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/ |
40 | 42 | `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. |
41 | `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). | |
43 | `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). | |
42 | 44 | `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/. |
43 | 45 | `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`. |
44 | 46 | `secure_image_url` | `false` | Set to `true` to use https for the avatar image url returned in the auth hash. |
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 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): | |
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 | site: 'https://graph.facebook.com/v3.0', | |
65 | authorize_url: "https://www.facebook.com/v3.0/dialog/oauth" | |
66 | site: 'https://graph.facebook.com/v7.0', | |
67 | authorize_url: "https://www.facebook.com/v7.0/dialog/oauth" | |
66 | 68 | } |
67 | 69 | end |
68 | 70 | ``` |
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 |
0 | 0 | PATH |
1 | remote: ../ | |
1 | remote: .. | |
2 | 2 | specs: |
3 | omniauth-facebook (3.0.0) | |
3 | omniauth-facebook (6.0.0) | |
4 | 4 | omniauth-oauth2 (~> 1.2) |
5 | 5 | |
6 | 6 | GEM |
7 | 7 | remote: https://rubygems.org/ |
8 | 8 | specs: |
9 | backports (3.6.8) | |
10 | faraday (0.9.2) | |
9 | backports (3.15.0) | |
10 | faraday (1.0.0) | |
11 | 11 | multipart-post (>= 1.2, < 3) |
12 | hashie (3.4.4) | |
13 | jwt (1.5.1) | |
14 | multi_json (1.12.1) | |
15 | multi_xml (0.5.5) | |
16 | multipart-post (2.0.0) | |
17 | oauth2 (1.1.0) | |
18 | faraday (>= 0.8, < 0.10) | |
19 | jwt (~> 1.0, < 1.5.2) | |
12 | hashie (3.6.0) | |
13 | jwt (2.2.1) | |
14 | multi_json (1.14.1) | |
15 | multi_xml (0.6.0) | |
16 | multipart-post (2.1.1) | |
17 | mustermann (1.1.1) | |
18 | ruby2_keywords (~> 0.0.1) | |
19 | oauth2 (1.4.2) | |
20 | faraday (>= 0.8, < 2.0) | |
21 | jwt (>= 1.0, < 3.0) | |
20 | 22 | multi_json (~> 1.3) |
21 | 23 | multi_xml (~> 0.5) |
22 | 24 | rack (>= 1.2, < 3) |
23 | omniauth (1.3.1) | |
24 | hashie (>= 1.2, < 4) | |
25 | rack (>= 1.0, < 3) | |
26 | omniauth-oauth2 (1.4.0) | |
27 | oauth2 (~> 1.0) | |
28 | omniauth (~> 1.2) | |
29 | rack (1.6.4) | |
30 | rack-protection (1.5.3) | |
25 | omniauth (1.9.0) | |
26 | hashie (>= 3.4.6, < 3.7.0) | |
27 | rack (>= 1.6.2, < 3) | |
28 | omniauth-oauth2 (1.6.0) | |
29 | oauth2 (~> 1.1) | |
30 | omniauth (~> 1.9) | |
31 | rack (2.1.1) | |
32 | rack-protection (2.0.8.1) | |
31 | 33 | rack |
32 | rack-test (0.6.3) | |
33 | rack (>= 1.0) | |
34 | sinatra (1.4.7) | |
35 | rack (~> 1.5) | |
36 | rack-protection (~> 1.4) | |
37 | tilt (>= 1.3, < 3) | |
38 | sinatra-contrib (1.4.7) | |
39 | backports (>= 2.0) | |
34 | ruby2_keywords (0.0.2) | |
35 | sinatra (2.0.8.1) | |
36 | mustermann (~> 1.0) | |
37 | rack (~> 2.0) | |
38 | rack-protection (= 2.0.8.1) | |
39 | tilt (~> 2.0) | |
40 | sinatra-contrib (2.0.8.1) | |
41 | backports (>= 2.8.2) | |
40 | 42 | multi_json |
41 | rack-protection | |
42 | rack-test | |
43 | sinatra (~> 1.4.0) | |
44 | tilt (>= 1.3, < 3) | |
43 | mustermann (~> 1.0) | |
44 | rack-protection (= 2.0.8.1) | |
45 | sinatra (= 2.0.8.1) | |
46 | tilt (~> 2.0) | |
45 | 47 | sinatra-reloader (1.0) |
46 | 48 | sinatra-contrib |
47 | tilt (2.0.5) | |
49 | tilt (2.0.10) | |
48 | 50 | |
49 | 51 | PLATFORMS |
50 | 52 | ruby |
53 | x64-mingw32 | |
51 | 54 | |
52 | 55 | DEPENDENCIES |
53 | 56 | omniauth-facebook! |
55 | 58 | sinatra-reloader |
56 | 59 | |
57 | 60 | BUNDLED WITH |
58 | 1.12.5 | |
61 | 1.17.2 |
0 | 0 | require 'sinatra' |
1 | 1 | require "sinatra/reloader" |
2 | 2 | require 'yaml' |
3 | require 'json' | |
3 | 4 | |
4 | 5 | # configure sinatra |
5 | 6 | set :run, false |
26 | 27 | <script type="text/javascript"> |
27 | 28 | window.fbAsyncInit = function() { |
28 | 29 | FB.init({ |
29 | appId: '#{ENV['APP_ID']}', | |
30 | version: 'v2.6', | |
30 | appId: '#{ENV['FACEBOOK_APP_ID']}', | |
31 | version: 'v4.0', | |
31 | 32 | cookie: true // IMPORTANT must enable cookies to allow the server to access the session |
32 | 33 | }); |
33 | 34 | console.log("fb init"); |
80 | 81 | # - ajax request made here for client-side flow |
81 | 82 | get '/auth/:provider/callback' do |
82 | 83 | content_type 'application/json' |
83 | MultiJson.encode(request.env) | |
84 | JSON.dump(request.env) | |
84 | 85 | end |
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/v4.0', | |
15 | authorize_url: "https://www.facebook.com/v4.0/dialog/oauth", | |
16 | 16 | token_url: 'oauth/access_token' |
17 | 17 | } |
18 | 18 | |
20 | 20 | header_format: 'OAuth %s', |
21 | 21 | param_name: 'access_token' |
22 | 22 | } |
23 | ||
24 | option :authorization_code_from_signed_request_in_cookie, nil | |
23 | 25 | |
24 | 26 | option :authorize_options, [:scope, :display, :auth_type] |
25 | 27 | |
75 | 77 | # phase and it must match during the access_token phase: |
76 | 78 | # https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L477 |
77 | 79 | def callback_url |
78 | if @authorization_code_from_signed_request_in_cookie | |
80 | if options.authorization_code_from_signed_request_in_cookie | |
79 | 81 | '' |
80 | 82 | else |
81 | 83 | # Fixes regression in omniauth-oauth2 v1.4.0 by https://github.com/intridea/omniauth-oauth2/commit/85fdbe117c2a4400d001a6368cc359d88f40abc7 |
130 | 132 | yield |
131 | 133 | elsif code_from_signed_request = signed_request_from_cookie && signed_request_from_cookie['code'] |
132 | 134 | request.params['code'] = code_from_signed_request |
133 | @authorization_code_from_signed_request_in_cookie = true | |
135 | options.authorization_code_from_signed_request_in_cookie = true | |
134 | 136 | # NOTE The code from the signed fbsr_XXX cookie is set by the FB JS SDK will confirm that the identity of the |
135 | 137 | # user contained in the signed request matches the user loading the app. |
136 | 138 | original_provider_ignores_state = options.provider_ignores_state |
139 | 141 | yield |
140 | 142 | ensure |
141 | 143 | request.params.delete('code') |
142 | @authorization_code_from_signed_request_in_cookie = false | |
144 | options.authorization_code_from_signed_request_in_cookie = false | |
143 | 145 | options.provider_ignores_state = original_provider_ignores_state |
144 | 146 | end |
145 | 147 | else |
158 | 160 | uri_class = options[:secure_image_url] ? URI::HTTPS : URI::HTTP |
159 | 161 | site_uri = URI.parse(client.site) |
160 | 162 | url = uri_class.build({host: site_uri.host, path: "#{site_uri.path}/#{uid}/picture"}) |
163 | query = { access_token: access_token.token } | |
161 | 164 | |
162 | query = if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol) | |
163 | { type: options[:image_size] } | |
165 | if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol) | |
166 | query[:type] = options[:image_size] | |
164 | 167 | elsif options[:image_size].is_a?(Hash) |
165 | options[:image_size] | |
168 | query.merge!(options[:image_size]) | |
166 | 169 | end |
167 | url.query = Rack::Utils.build_query(query) if query | |
170 | ||
171 | url.query = Rack::Utils.build_query(query) | |
168 | 172 | |
169 | 173 | url.to_s |
170 | 174 | end |
7 | 7 | s.authors = ['Mark Dodwell', 'Josef Šimánek'] |
8 | 8 | s.email = ['mark@madeofcode.com', 'retro@ballgag.cz'] |
9 | 9 | s.summary = 'Facebook OAuth2 Strategy for OmniAuth' |
10 | s.homepage = 'https://github.com/mkdynamic/omniauth-facebook' | |
10 | s.homepage = 'https://github.com/simi/omniauth-facebook' | |
11 | 11 | s.license = 'MIT' |
12 | 12 | |
13 | 13 | s.files = `git ls-files`.split("\n") |
40 | 40 | |
41 | 41 | @client_id = '123' |
42 | 42 | @client_secret = '53cr3tz' |
43 | @options = {} | |
43 | 44 | end |
44 | 45 | |
45 | 46 | def strategy |
52 | 53 | end |
53 | 54 | end |
54 | 55 | |
55 | Dir[File.expand_path('../support/**/*', __FILE__)].each &method(:require) | |
56 | Dir[File.expand_path('../support/**/*', __FILE__)].each(&method(:require)) |
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/v4.0', 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/v4.0/dialog/oauth', strategy.client.options[:authorize_url] | |
16 | 16 | end |
17 | 17 | |
18 | 18 | test 'has correct token url with versioning' do |
94 | 94 | end |
95 | 95 | |
96 | 96 | class InfoTest < StrategyTestCase |
97 | def setup | |
98 | super | |
99 | @access_token = stub('OAuth2::AccessToken') | |
100 | @access_token.stubs(:token).returns('test_access_token') | |
101 | end | |
102 | ||
97 | 103 | test 'returns the secure facebook avatar url when `secure_image_url` option is specified' do |
98 | 104 | @options = { secure_image_url: true } |
99 | 105 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
100 | 106 | strategy.stubs(:raw_info).returns(raw_info) |
101 | assert_equal 'https://graph.facebook.com/v2.6/321/picture', strategy.info['image'] | |
107 | strategy.stubs(:access_token).returns(@access_token) | |
108 | assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
102 | 109 | end |
103 | 110 | |
104 | 111 | test 'returns the image_url based of the client site' do |
105 | 112 | @options = { secure_image_url: true, client_options: {site: "https://blah.facebook.com/v2.2"}} |
106 | 113 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
107 | 114 | strategy.stubs(:raw_info).returns(raw_info) |
108 | assert_equal 'https://blah.facebook.com/v2.2/321/picture', strategy.info['image'] | |
115 | strategy.stubs(:access_token).returns(@access_token) | |
116 | assert_equal "https://blah.facebook.com/v2.2/321/picture?access_token=test_access_token", strategy.info['image'] | |
109 | 117 | end |
110 | 118 | |
111 | 119 | test 'returns the image with size specified in the `image_size` option' do |
112 | 120 | @options = { image_size: 'normal' } |
113 | 121 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
114 | 122 | strategy.stubs(:raw_info).returns(raw_info) |
115 | assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image'] | |
123 | strategy.stubs(:access_token).returns(@access_token) | |
124 | assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token&type=normal', strategy.info['image'] | |
116 | 125 | end |
117 | 126 | |
118 | 127 | test 'returns the image with size specified as a symbol in the `image_size` option' do |
119 | 128 | @options = { image_size: :normal } |
120 | 129 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
121 | 130 | strategy.stubs(:raw_info).returns(raw_info) |
122 | assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image'] | |
131 | strategy.stubs(:access_token).returns(@access_token) | |
132 | assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token&type=normal', strategy.info['image'] | |
123 | 133 | end |
124 | 134 | |
125 | 135 | test 'returns the image with width and height specified in the `image_size` option' do |
126 | 136 | @options = { image_size: { width: 123, height: 987 } } |
127 | 137 | raw_info = { 'name' => 'Fred Smith', 'id' => '321' } |
128 | 138 | strategy.stubs(:raw_info).returns(raw_info) |
139 | strategy.stubs(:access_token).returns(@access_token) | |
129 | 140 | assert_match 'width=123', strategy.info['image'] |
130 | 141 | assert_match 'height=987', strategy.info['image'] |
131 | assert_match 'http://graph.facebook.com/v2.6/321/picture?', strategy.info['image'] | |
142 | assert_match 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
132 | 143 | end |
133 | 144 | end |
134 | 145 | |
137 | 148 | super |
138 | 149 | @raw_info ||= { 'name' => 'Fred Smith' } |
139 | 150 | strategy.stubs(:raw_info).returns(@raw_info) |
151 | ||
152 | access_token = stub('OAuth2::AccessToken') | |
153 | access_token.stubs(:token).returns('test_access_token') | |
154 | strategy.stubs(:access_token).returns(access_token) | |
140 | 155 | end |
141 | 156 | |
142 | 157 | test 'returns the name' do |
175 | 190 | |
176 | 191 | test 'returns the facebook avatar url' do |
177 | 192 | @raw_info['id'] = '321' |
178 | assert_equal 'http://graph.facebook.com/v2.6/321/picture', strategy.info['image'] | |
193 | assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image'] | |
179 | 194 | end |
180 | 195 | |
181 | 196 | test 'returns the Facebook link as the Facebook url' do |
214 | 229 | super |
215 | 230 | @raw_info ||= { 'name' => 'Fred Smith' } |
216 | 231 | strategy.stubs(:raw_info).returns(@raw_info) |
232 | ||
233 | access_token = stub('OAuth2::AccessToken') | |
234 | access_token.stubs(:token).returns('test_access_token') | |
235 | strategy.stubs(:access_token).returns(access_token) | |
217 | 236 | end |
218 | 237 | |
219 | 238 | test 'has no email key' do |
257 | 276 | @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'} |
258 | 277 | end |
259 | 278 | |
260 | test 'performs a GET to https://graph.facebook.com/v2.6/me' do | |
279 | test 'performs a GET to https://graph.facebook.com/v4.0/me' do | |
261 | 280 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
262 | 281 | strategy.stubs(:access_token).returns(@access_token) |
263 | 282 | params = {params: @options} |
265 | 284 | strategy.raw_info |
266 | 285 | end |
267 | 286 | |
268 | test 'performs a GET to https://graph.facebook.com/v2.6/me with locale' do | |
287 | test 'performs a GET to https://graph.facebook.com/v4.0/me with locale' do | |
269 | 288 | @options.merge!({ locale: 'cs_CZ' }) |
270 | 289 | strategy.stubs(:access_token).returns(@access_token) |
271 | 290 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
274 | 293 | strategy.raw_info |
275 | 294 | end |
276 | 295 | |
277 | test 'performs a GET to https://graph.facebook.com/v2.6/me with info_fields' do | |
296 | test 'performs a GET to https://graph.facebook.com/v4.0/me with info_fields' do | |
278 | 297 | @options.merge!({info_fields: 'about'}) |
279 | 298 | strategy.stubs(:access_token).returns(@access_token) |
280 | 299 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
283 | 302 | strategy.raw_info |
284 | 303 | end |
285 | 304 | |
286 | test 'performs a GET to https://graph.facebook.com/v2.6/me with default info_fields' do | |
305 | test 'performs a GET to https://graph.facebook.com/v4.0/me with default info_fields' do | |
287 | 306 | strategy.stubs(:access_token).returns(@access_token) |
288 | 307 | strategy.stubs(:appsecret_proof).returns(@appsecret_proof) |
289 | 308 | params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}} |
451 | 470 | end |
452 | 471 | |
453 | 472 | test 'empty param' do |
454 | assert_equal nil, strategy.send(:signed_request_from_cookie) | |
473 | assert_nil strategy.send(:signed_request_from_cookie) | |
455 | 474 | end |
456 | 475 | end |
457 | 476 |