मैंने नई रेल ऐप बनाई और डेविस और omniauth-facebook मणि स्थापित किया।omniauth- facebook ईमेल पता नहीं मिल सकता
और परीक्षण पर्यावरण के रूप में, मेरे फेसबुक ऐप को सेट करना।
तो, मैंने फेसबुक के माध्यम से लॉग इन किया और अपना नया रेल ऐप साइन अप किया, लेकिन request.env में ईमेल address.info शामिल नहीं था।
इस लौटा दिया जाता है request.env [ 'omniauth.auth']
{
"provider" => "facebook",
"uid" => "xxxxxxxxxxxx",
"info" => {
"name" => "xxxxxxx",
"image" => "http://graph.facebook.com/xxx/picture"
},
"credentials" => {
"token" => "tokenstring",
"expires_at" => xxxxxxxxx,
"expires" => true
},
"extra" => {
"raw_info" => {
"name" => "xxx xxxx",
"id" => "xxxxxxxxx"
}
}
}
यह request.env रैक [ 'omniauth.auth'] [ 'जानकारी'] [ 'ईमेल']
मैं oauth के माध्यम से फेसबुक से ईमेल पता कैसे प्राप्त कर सकता हूं? कृपया कोई मेरी मदद करो।
रेल ver 4.2.3 रूबी ver 2.2.2p95
यह रत्न संस्करण
omniauth (1.2.2)
omniauth-facebook (2.0.1)
devise (3.5.1)
config/initializers/devise.rb
config.omniauth :facebook, 'appId', 'appSeacret', scope: 'email,public_profile'
एप्लिकेशन/नियंत्रक/है है omniauth_callbacks_controller.rb
def all_provider
user = User.from_omniauth(request.env['omniauth.auth'])
if user.persisted?
sign_in_and_redirect user
else
session['devise.user_attributes'] = user.attributes
redirect_to new_user_registration_url
end
end
alias_method :facebook, :all_provider
एप्लिकेशन/मॉडल/user.rb
def from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
end
end
2015/7/11
पर मैं अपना पुराना परीक्षण फेसबुक आवेदन के साथ एक ही कोड का पुनः प्रयास करें, और पूर्ण public_profile और ईमेल मिल सकता है।
क्या नए फेसबुक ऐप के लिए कोई प्रतिबंध जोड़ा गया है ?? कोई जानता है?
मेरे लिए काम नहीं करता है, मुझे नहीं पता कि क्यों, मेरे devise config में config.omniauth है: facebook, p.key, p.secret, scope: 'ईमेल', info_fields: 'ईमेल, नाम' लेकिन जब प्राप्त करने का प्रयास करें ईमेल उपयोगकर्ता omniauth [: जानकारी] [: ईमेल], यह खाली है –
मेरे लिए एक ही समस्या मौजूद है – Rubyist
यह काम नहीं करता है। – Red