当每个请求的应用程序ID和应用程序秘密不同时,使用omniauth-facebook吗? [英] Use omniauth-facebook when app id and app secret are different for each request?
本文介绍了当每个请求的应用程序ID和应用程序秘密不同时,使用omniauth-facebook吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
omniauth-facebook 自述文件提到了如何在初始化程序中进行设置以及如何设置诸如scope
之类的选项仅根据请求.我想知道是否还可以为每个请求设置应用程序ID和应用程序密码.
The omniauth-facebook README mentions how to set it up in an initializer and how to set options like scope
per request only. I wonder if it is possible to set app id and app secret per request as well.
推荐答案
您可以执行以下操作:
在您的omniauth.rb上,执行以下操作:
On your omniauth.rb, do this:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook,:setup => true
end
然后,您必须在控制器上定义以下内容:
Then on your controller you have to define the following:
def setup
request.env['omniauth.strategy'].options[:client_id] = @site.facebook_key
request.env['omniauth.strategy'].options[:client_secret] = @site.facebook_secret
render :text => "Setup complete.", :status => 404
end
当然,您必须在route.rb上添加关联的路由.
Of course you have to add the associated routes, on your routes.rb.
#Facebook Omniauth routes
match '/auth/facebook/callback' => 'session#authorize_callback'
match '/auth/facebook/setup' => 'session#setup'
祝你好运
关于. 伊万.
这篇关于当每个请求的应用程序ID和应用程序秘密不同时,使用omniauth-facebook吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文