10

当前的omniauth-facebook似乎有一些问题,我想知道是否有人对此有答案。

第一个问题是无效凭据问题。由于这个问题,我无法使用客户端授权登录到我的应用程序。但是,这可以通过将 facebook-omniauth 降级到 1.4.0 版本来解决。(参考

但是,现在我遇到了第二个问题NoAuthorizationCodeError,并带有错误消息:

OmniAuth Strategies Facebook NoAuthorizationCodeError 
(must pass either a `code` parameter or a signed request 
(via `signed_request` parameter):

这是在这里提出的,但接受的答案建议实际上再次升级到 1.4.1 版本,这会使之前的无效凭据问题再次发生。所以这对我来说不是一个选择。

NoAuthorizationCodeError当我尝试通过internet explorer登录 Facebook iFrame 内的应用程序(从应用程序中心搜索我的应用程序)时,就会发生这种情况。在 chrome 或 firefox 上一切正常。还有一个github issue准确地指出了这个问题,但还没有人想出答案。我也尝试降级到omniauth-facebook 1.3.0 版本,但没有任何区别。我还尝试传递signed_request如下参数:

window.location = '/auth/facebook/callback', 
{ signed_request: response.authResponse.signedRequest }

但是,它没有任何区别(在 IE 上,错误仍然存​​在),我不确定这是否是将代码作为参数传递的正确方法(我如何检查?)

我认为我的设置没有问题。我真的很感激在这件事上的任何帮助。

更新:

我升级到 1.4.1 版本时没有出现无效凭据问题,但是当我通过 Internet Explorer 访问 Facebook 内部的应用程序时,仍然会出现 NoAuthorizationCodeError。检查我的 Github问题

更新:

我降级到 1.4.0 版本,并添加了 signedRequest 参数。

<script>
function login() {
  FB.login(function(response) {
    if (response.authResponse) {
      window.location = '/auth/facebook/callback?' + $.param({ signed_request: response.authResponse.signedRequest })
    } 
  }, {scope: 'email,publish_stream,publish_actions'});
}
</script>

日志中没有错误或警报,一切都按预期工作。但是,如果我通过 Internet Explorer 在 Facebook iFrame 中登录,即使在回调阶段启动后它也不会登录。我想原来的问题已经解决了,但是当没有任何类型的错误消息时,我不知道如何调试它。

问题:当我使用 Internet Explorer 在 Facebook iFrame 中为我的应用程序单击“使用 Facebook 登录”时,授权过程完成后我没有登录。这个问题只发生在那个特定的环境中,我很难找出原因。

2013-02-22T01:10:40+00:00 app[web.1]: Started GET "/auth/facebook/callback?signed_request=LONGSTRING" for 200.1.102.103 at 2013-02-22 01:10:40 +0000
2013-02-22T01:10:40+00:00 app[web.1]: (facebook) Callback phase initiated.
2013-02-22T01:10:40+00:00 app[web.1]: Processing by SessionsController#create_facebook as HTML
2013-02-22T01:10:40+00:00 app[web.1]:   Parameters: {"signed_request"=>"LONGSTRING", "provider"=>"facebook"}
2013-02-22T01:10:40+00:00 app[web.1]:   User Load (1.6ms)  SELECT "users".* FROM "users" WHERE "users"."provider" = 'facebook' AND "users"."uid" = 'MYUID' LIMIT 1
2013-02-22T01:10:40+00:00 app[web.1]:    (0.8ms)  BEGIN
2013-02-22T01:10:40+00:00 app[web.1]:   User Exists (1.0ms)  SELECT 1 AS one FROM "users" WHERE ("users"."name" = 'MYNAME' AND "users"."id" != 3) LIMIT 1
2013-02-22T01:10:40+00:00 app[web.1]:    (0.9ms)  COMMIT
2013-02-22T01:10:40+00:00 app[web.1]: Redirected to http://MYAPP.COM
2013-02-22T01:10:40+00:00 app[web.1]: Completed 302 Found in 10ms (ActiveRecord: 4.2ms)

同样,在任何其他环境中,授权在所有浏览器中都能完美运行。仅当我尝试通过 Internet Explorer 在 Facebook 中登录时才会出现此问题。

我的环境:omniauth-facebook 1.4.0、omniauth 1.1.1、oauth2 0.8.0、Rails 3.2.11

由于最新版本中的凭据无效错误,我故意将omniauth-facebook 从1.4.1 降级到1.4.0 。

4

3 回答 3

1

利用omniauth (1.1.3)、oauth2 (0.8.1) 和omniauth-facebook (1.4.1)。

这些不会有任何错误

于 2013-05-02T11:41:11.110 回答
0

fastcatchSO 帖子中借助从 omniauth-exceptions 获取更多信息说,

... OmniAuth strategies [...], if they encounter a problem, call the method fail! and pass in a symbol describing the problem like :invalid_credentials and the exception they encountered. The fail! method ends up calling OmniAuth.config.on_failure and passing in the Rack environment (after doing a few other things like sticking the exception into the environment...

于 2013-03-01T14:43:19.513 回答
0

因为您在使用 iframe 时仅在 Internet Explorer 中看到该问题,所以它可能是 P3P 问题。

请参阅http://www.slideshare.net/cmercier/things-i-learned-writing-a-facebook-canvas-appCookie 被阻止/未保存在 Internet Explorer 的 IFRAME 中

Internet Explorer 对 IFRAME 页面的信任级别较低(IE 将此称为“第三方”内容)。如果 IFRAME 内的页面没有隐私政策,则其 cookie 将被阻止(由状态栏中的眼睛图标指示,当您单击它时,它会显示被阻止的 URL 列表)。...在这种情况下,当 cookie 被阻止时,不会发送会话标识符,并且目标脚本会抛出“未找到会话”错误。

尝试添加rack-p3p gem,看看是否有帮助!

于 2013-08-12T15:07:13.787 回答