Class: OmniAuth::Strategies::Facebook
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Facebook
- Defined in:
- lib/j1_app/omniauth/strategies/facebook.rb
Defined Under Namespace
Classes: NoAuthorizationCodeError
Constant Summary collapse
- DEFAULT_SCOPE =
OAuth client settings
'email'
Instance Method Summary collapse
- #access_token_options ⇒ Object
-
#authorize_params ⇒ Object
You can pass
display
,scope
, orauth_type
params to the auth request, if you need to set them dynamically. - #callback_phase ⇒ Object
-
#callback_url ⇒ Object
NOTE If we’re using code from the signed request then FB sets the redirect_uri to ” during the authorize phase and it must match during the access_token phase: github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L477.
- #info_options ⇒ Object
- #raw_info ⇒ Object
Instance Method Details
#access_token_options ⇒ Object
116 117 118 |
# File 'lib/j1_app/omniauth/strategies/facebook.rb', line 116 def ..inject({}) { |h,(k,v)| h[k.to_sym] = v; h } end |
#authorize_params ⇒ Object
You can pass display
, scope
, or auth_type
params to the auth request, if you need to set them dynamically. You can also set these options in the OmniAuth config :authorize_params option.
For example: /auth/facebook?display=popup
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/j1_app/omniauth/strategies/facebook.rb', line 124 def super.tap do |params| %w[display scope auth_type].each do |v| if request.params[v] params[v.to_sym] = request.params[v] end end params[:scope] ||= DEFAULT_SCOPE end end |
#callback_phase ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/j1_app/omniauth/strategies/facebook.rb', line 94 def callback_phase do super end rescue NoAuthorizationCodeError => e fail!(:no_authorization_code, e) rescue OmniAuth::Facebook::SignedRequest::UnknownSignatureAlgorithmError => e fail!(:unknown_signature_algorithm, e) end |
#callback_url ⇒ Object
NOTE If we’re using code from the signed request then FB sets the redirect_uri to ” during the authorize
phase and it must match during the access_token phase:
https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L477
107 108 109 110 111 112 113 114 |
# File 'lib/j1_app/omniauth/strategies/facebook.rb', line 107 def callback_url if @authorization_code_from_signed_request_in_cookie '' else # Fixes regression in omniauth-oauth2 v1.4.0 by https://github.com/intridea/omniauth-oauth2/commit/85fdbe117c2a4400d001a6368cc359d88f40abc7 [:callback_url] || (full_host + script_name + callback_path) end end |
#info_options ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/j1_app/omniauth/strategies/facebook.rb', line 86 def params = {appsecret_proof: appsecret_proof} params.merge!({fields: ([:info_fields] || 'name,email')}) params.merge!({locale: [:locale]}) if [:locale] { params: params } end |
#raw_info ⇒ Object
82 83 84 |
# File 'lib/j1_app/omniauth/strategies/facebook.rb', line 82 def raw_info @raw_info ||= access_token.get('me', ).parsed || {} end |