【发布时间】:2014-04-18 15:09:28
【问题描述】:
我收到了
OmniAuth::Strategies::OAuth2::CallbackError 在 /auth/google/callback csrf_detected |检测到 CSRF
我的代码:
require 'sinatra'
require "sinatra/json"
require "sinatra/config_file"
require 'omniauth-oauth2'
require 'omniauth-google-oauth2'
use Rack::Logger
config_file "config/app_config.yml"
use Rack::Session::Cookie, secret: '5fb7w345y3489f523y4h'
configure do
enable :sessions
end
use OmniAuth::Builder do
provider :google_oauth2, settings.google[:client_id], settings.google[:secret],
{
:scope => "userinfo.profile",
:access_type => "offline",
:prompt => "select_account consent",
:name => "google"
}
end
get '/list' do
json get_list
end
get '/' do
%Q|<a href='/auth/google'>Sign in with Google</a>|
end
get '/auth/:name/callback' do
@auth = request.env['omniauth.auth']
@auth.inspect
end
我的回调同时返回代码和状态。
【问题讨论】:
-
我刚刚重启了服务器,一切都很好:P
标签: ruby oauth-2.0 sinatra omniauth