Facebook migration from api v2.3 to v2.4 - Rails omniauth -


i have old app in rails 4.0.0. until 8th of jul 2017 facebook registering works ok, v2.3 deprecated , users can't register on page.

here user.rb code:

def self.from_omniauth(auth)      oauth = koala::facebook::oauth.new('xxx', 'xxxx')     new_access_info = oauth.exchange_access_token_info auth.credentials.token      new_access_token = new_access_info["access_token"]     new_access_expires_at = datetime.now + new_access_info["expires"].to_i.seconds      user = where(auth.slice(:provider, :uid)).first      if !user.present?       user = where(email: auth.info.email).first        if user.present?         user.provider = auth.provider         user.uid = auth.uid         user.oauth_token = new_access_token         user.oauth_expires_at = new_access_expires_at         user.save!       else         user = user.new         user.provider = auth.provider         user.uid = auth.uid         user.email = auth.info.email         user.profile.gender = 1         user.confirmed_at = time.now         user.first_name = auth.info.first_name         user.fb_image_url = auth.info.image          user.oauth_token = new_access_token         user.oauth_expires_at = new_access_expires_at          @str = user.fb_image_url.to_s         @index = @str.index('type')         @sliced = @str.slice(0, @index)         @slices = @sliced + 'width=800&height=800'         user.fb_image_url = @slices         if auth.info.gender == 'female'             user.fb_gender = 1         elsif auth.fb_gender == 'male'             user.fb_gender = 2         end        end      end       user   end 

and here /initializers/devise.rb :

require "omniauth-facebook"    config.omniauth :facebook, 'xxxxxxx', 'xxxxxxxxx',      scope: 'email,public_profile',      info_fields: 'email',      client_options: {     site: 'https://graph.facebook.com/v2.4', authorize_url: "https://www.facebook.com/v2.4/dialog/oauth"},     token_params: { parse: :json } 

gemfile - gem 'omniauth-facebook', '1.4.0'

what need change make work ? right after click "register facebook" user redirected facebook, login, accept permission , after redirect site - redirect /users/sign_in - not earlier /users/sign_up fill few more fields.

i stop making apps in rails not know how make it. help

edit:

ok, works facebook not return email need add email field after redirect site. why email blank ?

have tried adding in devise.rb:

config.omniauth :facebook, "key", "secret", scope: 'email', info_fields: 'email, name'

also check https://github.com/mkdynamic/omniauth-facebook more info.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -