· 8 years ago · Nov 24, 2017, 03:24 PM
1`config.omniauth :facebook, 'AppID', 'secretkey', scope: 'email'
2
3class User < ApplicationRecord
4 devise :database_authenticatable, :registerable, :recoverable,
5 :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:facebook]
6
7 def self.from_omniauth(auth)
8 where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
9 user.email = auth.info.email
10 user.name = auth.info.name
11 user.provider = auth.provider
12 user.uid = auth.uid
13 user.password = Devise.friendly_token[0,20]
14 end
15 end
16end
17
18`config.omniauth :facebook, 'AppID', 'secretkey', scope: 'email', info_fields: 'first_name`