我完全按照http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/#changes中的说明进行操作
要在我的应用程序中实现Devise Omniauth Linkedin,我做了以下工作,
在devise.rb中
config.omniauth :linked_in, "*******", "**********"
Run Code Online (Sandbox Code Playgroud)
在我的用户模型user.rb中,我有这个
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :lockable, :confirmable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
TEMP_EMAIL_PREFIX = 'change@me'
TEMP_EMAIL_REGEX = /\Achange@me/
validates_format_of :email, :without => TEMP_EMAIL_REGEX, on: :update
def self.find_for_oauth(auth, signed_in_resource = nil)
# Get the identity and user if they exist
identity = Identity.find_for_oauth(auth)
# If a signed_in_resource is provided it always overrides …Run Code Online (Sandbox Code Playgroud)