5

用户通过我的移动应用程序通过 facebook 进行身份验证后,如何实现正常的门卫 oauth2 流程?

PS我正在使用 doorkeeper gem 为我的移动应用程序实现 oauth2 提供程序。我使用资源所有者密码凭据流通过用户的用户名和密码来实现身份验证。

因此,如果用户首先通过移动应用程序通过 facebook 进行身份验证,我如何使用 facebook 访问令牌通过门卫对用户进行身份验证。所以在这种情况下不存在用户名/密码(哪个门卫抛出缺少参数的错误)。

实现此流程的正确方法是什么。

 1. User authenticates from facebook through the mobile app.
 2. Facebook access token is passed to the API server.
 3. If the access token is valid, the api server returns the
    doorkeeper access token.
 4. In case the access token is not valid, the api server returns 401 Unauthorized.

实施此流程的正确方法是什么?非常感谢一些正确方向的指导。

4

2 回答 2

6

对现有门卫授权流程的扩展,正好解决了这个问题: https ://github.com/doorkeeper-gem/doorkeeper-grants_assertion

断言流程是提供者的 access_token 之间的交换,用于获取来自您的 oauth 提供者的访问令牌。

于 2014-07-18T09:06:04.913 回答
3

有一个拉取请求来修复“NoMethodError (undefined method 'resource_owner_from_assertion' for #)”:

更改您的 Gemfile:

gem “doorkeeper-grants_assertion”,github:“Inittec/doorkeeper-grants_assertion”,分支:“master”

于 2014-10-08T17:39:45.830 回答