Я пытаюсь извлечь маркер oauth, но не могу этого сделать. Я использую OmniAuth для входа в системе с помощью facebook.I может войти в системе, но я хочу, чтобы принести функциональные возможности, такие как данные профильного user.So вот почему я хочу, чтобы принести лексему Вот мой код
[omniauth.rb]Rails fetch oauth token и дополнительные поля
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'my-app-key', 'my-app-id', {:client_options => {:ssl => {:ca_file => Rails.root.join("cacert.pem").to_s}}}
end
[user.rb]
class User < ActiveRecord::Base
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user
user.save
end
end
end
[application_controller]
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_user
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
end
[session_controller]
class SessionsController < ApplicationController
def create
user = User.from_omniauth(env["omniauth.auth"])
session[:user_id] = user.id
redirect_to root_path
end
def destroy
session[:user_id] = nil
redirect_to root_path
end
end
мне нужно сделать, чтобы удалить это у провайдера: facebook, 'мое приложение-ключ', 'мое приложение-идентификатор', {: client_options => {: ssl => {: ca_file => Rails.root.join ("cacert.pem"). to_s}}} –
нет, вы можете заменить вышеуказанный код. однако вам нужно заменить переменные окружения на 'app_id' и' secret_id' – user2954587
и какие изменения мне нужно внести в моей модели User.rb –