Class: OmniAuth::Strategies::Facebook2
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Facebook2
show all
- Defined in:
- lib/omniauth/strategies/facebook2.rb
Overview
OmniAuth strategy for Facebook OAuth2.
Defined Under Namespace
Classes: NoAuthorizationCodeError
Constant Summary
collapse
- DEFAULT_SCOPE =
"email"
- DEFAULT_FACEBOOK_API_VERSION =
"v25.0"
- DEFAULT_INFO_FIELDS =
"name,email"
- DEFAULT_TOKEN_URL =
"oauth/access_token"
Instance Method Summary
collapse
Instance Method Details
#access_token_options ⇒ Object
129
130
131
|
# File 'lib/omniauth/strategies/facebook2.rb', line 129
def access_token_options
options.access_token_options.to_h.transform_keys(&:to_sym)
end
|
#authorize_params ⇒ Object
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/omniauth/strategies/facebook2.rb', line 133
def authorize_params
super.tap do |params|
options.authorize_options.each do |key|
request_value = request.params[key.to_s]
params[key] = request_value unless blank?(request_value)
end
params[:scope] ||= options[:scope] || DEFAULT_SCOPE
end
end
|
#callback_phase ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/omniauth/strategies/facebook2.rb', line 95
def callback_phase
return fail_state_mismatch if missing_session_state?
with_authorization_code! { super }
rescue NoAuthorizationCodeError => e
fail!(:no_authorization_code, e)
rescue OmniAuth::Facebook2::SignedRequest::UnknownSignatureAlgorithmError => e
fail!(:unknown_signature_algorithm, e)
rescue NoMethodError => e
raise unless oauth_state_nil_compare_error?(e)
fail_state_mismatch
end
|
#callback_url ⇒ Object
117
118
119
120
121
|
# File 'lib/omniauth/strategies/facebook2.rb', line 117
def callback_url
return "" if options.authorization_code_from_signed_request_in_cookie
options[:callback_url] || super
end
|
#client ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/omniauth/strategies/facebook2.rb', line 109
def client
@client ||= ::OAuth2::Client.new(
options.client_id,
options.client_secret,
deep_symbolize(normalized_client_options)
)
end
|
#info_options ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/omniauth/strategies/facebook2.rb', line 85
def info_options
params = {
fields: options[:info_fields] || DEFAULT_INFO_FIELDS
}
params[:appsecret_proof] = appsecret_proof if options[:appsecret_proof]
params[:locale] = options[:locale] if options[:locale]
{params: params}
end
|
#query_string ⇒ Object
123
124
125
126
127
|
# File 'lib/omniauth/strategies/facebook2.rb', line 123
def query_string
return "" if request.params["code"]
super
end
|
#raw_info ⇒ Object
81
82
83
|
# File 'lib/omniauth/strategies/facebook2.rb', line 81
def raw_info
@raw_info ||= access_token.get("me", info_options).parsed || {}
end
|