使用omniauth来facebook连接具有不同权限的现有用户
我正在使用 devise/omniauth 进行 Facebook 身份验证并且效果很好。但是,我想添加一个流程,使现有(非 Facebook)用户能够将其帐户与 Facebook 连接。这需要不同的 Facebook 权限。所以我似乎找不到两件事
- 如何使用 devise/omniauth 请求 facebook 连接而不注销当前用户
- 请求用户的不同扩展权限(与 devise 配置文件中指定的权限不同)
有什么想法吗?谢谢
I'm using devise/omniauth to do facebook authentication and works great. However, I would like to add a flow where an existing (non-facebook) user has ability to connect his account with facebook. This would require different facebook permissions. so i can't seem to find two things
- how to use devise/omniauth to request facebook connect without logging out current user
- request different extended permissions from user (different from those specified in the devise configuration file)
any ideas? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1 的答案非常简单:只需将 if 路径添加到omniauth_callbacks_controller::process_callback 方法中,如下所示
这就是我在应用程序中所做的,并且工作正常。
关于问题 2,我不知道如何支持 2 种不同的 facebook 身份验证配置,但是我很难看出这对用户有什么用,因为他们需要在两条路径上获得一致的体验:“使用 facebook 登录”和“将您的帐户链接到 facebook ”。
(如果您仍然想走这条路,我会探索的一个想法是创建一个具有独立密钥和配置的新 Facebook 应用程序......)
希望这有所帮助。
Answer to 1 is pretty easy: just add a if path into the omniauth_callbacks_controller::process_callback method like this
This is what I do in my application and it works fine.
Regarding question 2 I do not know how to support 2 different facebook authentication configurations however I have hard time seeing how that is useful to users since they need a consistent experience across both path: "sign in using facebook" and "link your account to facebook".
(If you still want to pursue this path one idea I would explore is to create a new facebook application with its independent keys and configuration...)
Hope this help.
实现多层权限的一种简单方法是使用 Facebook Javascript SDK(如果需要,除了omniauth之外)。您可以简单地在每次调用时指定不同的“范围”参数,该参数指定所需的权限。我正在做的是让omniauth提供一组基本的权限,然后,在用户通过omniauth连接(从而将他们的数据存储在我们的数据库中),如果需要进一步的权限,我们会显示它们是基于 JS 的按钮,提供扩展的权限集。如果您想检查用户授予您哪些特定权限,您只需使用
me/permissions
API 调用即可。One simple way to implement multi-tier permissions is to use Facebook Javascript SDK(in addition to omniauth, if you want). You can simply specify different "scope" parameter, which specifies permissions required, at each call you want. What I'm doing is making omniauth provide a basic set of permissions, then, after the user has connected through omniauth(and thus stored their data in our DB), if further permissions are needed, we show them JS-based buttons which provide expanded sets of permissions. If you want to check what particular permissions a user has granted to you, you can simply use
me/permissions
API call.