laravel4 hybridauth facebook 身份验证失败!Facebook 返回了无效的用户 ID [英] laravel4 hybridauth facebook Authentication failed! Facebook returned an invalid user id

查看:20
本文介绍了laravel4 hybridauth facebook 身份验证失败!Facebook 返回了无效的用户 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我正在尝试将 Hybridauth 与 laravel 4 一起使用.但是,在尝试使用 facebook 登录时,我似乎变得很常见:

OK, I'm trying to use Hybridauth with laravel 4. However I seem to be getting the very common when trying to log in with facebook:

身份验证失败!Facebook 返回了无效的用户 ID.

Authentication failed! Facebook returned an invalid user id.

我已经阅读了所有其他帖子,但运气不佳,所以希望有人能够帮助我.

I have read all the other posts, and have had no luck, so just hoping someone may be able to help me.

我遵循了这个教程:http://www.mrcasual.com/on/coding/laravel4-package-management-with-composer/

并且尝试了其他几种配置都没有成功.

And have tried several other configurations to no success.

这是我的配置/hybridauth.php

Here is my config/hybridauth.php

<?php
return array(
    "base_url"   => "http://myapp.dev/social/auth/",
    "providers"  => array (
        "Facebook"   => array (
            "enabled"    => true,
            "keys"       => array ( "id" => "****", "secret" => "****" ),

        ),
    ),
);

这是我的路线:

Route::get('social/{action?}', array("as" => "hybridauth", function($action = "")
{
    // check URL segment
    if ($action == "auth") {
        // process authentication
        try {
            Hybrid_Endpoint::process();
        }

        catch (Exception $e) {
            // redirect back to http://URL/social/
            return Redirect::route('hybridauth');
        }
        return;
    }

    try {
        // create a HybridAuth object
        $socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php');
        // authenticate with Facebook
        $provider = $socialAuth->authenticate("Facebook");
        // fetch user profile
        $userProfile = $provider->getUserProfile();
    }

    catch(Exception $e) {
        // exception codes can be found on HybBridAuth's web site
        return $e->getMessage();
    }

    // access user profile data
    echo "Connected with: <b>{$provider->id}</b><br />";
    echo "As: <b>{$userProfile->displayName}</b><br />";
    echo "<pre>" . print_r( $userProfile, true ) . "</pre><br />";

    // logout
    $provider->logout();
}));

所以,当我访问myapp.dev/social"时,我被带到了 facebook 注册页面,一切似乎都正常,要求我允许对 myadd.dev 的权限.单击确定"后,我将转到以下 URL:http://myapp.ie/social#_=_ 显示错误的位置.

So, when I access "myapp.dev/social" I'm brought to the facebook sign up page everthing seems to work fine, asks me to allow permissions to myadd.dev. After I click OK I am brought to the following URL: http://myapp.ie/social#_=_ where the error is displayed.

不确定这是否相关:仅通过观察与 facebook 登录合作的其他网站.. 重定向 URL 类似于 http://somesite.dev/subdomain/#_=_ .换句话说,它们在#= 之前有一个斜线.这是我的问题,我该如何解决??对 hybridauth 非常陌生,因此非常感谢您的帮助.

Not sure if this is relevant: Just from observing other sites that in-cooperate a facebook login.. the redirect URL looks something like http://somesite.dev/subdomain/#_=_ . In other words they have a slash before the #=. Is this my problem, how do I fix it?? Very new to hybridauth so any help greatly appreciated thanks.

哦,我确实意识到这篇文章与其他帖子非常相似,但我还没有找到解决方案.

Oh I do realize that this post is very similar to other posts but I have yet to find a solution.

更新:确切的错误:身份验证失败.用户已取消身份验证或提供商拒绝连接.

推荐答案

在 base_facebook.php 中做以下操作

In base_facebook.php do following

  public static $CURL_OPTS = array(
    CURLOPT_CONNECTTIMEOUT => 50,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_USERAGENT      => 'facebook-php-3.2',
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_SSL_VERIFYHOST => false,
  );

  protected $trustForwarded = true;
  protected $allowSignedRequest = false;

这篇关于laravel4 hybridauth facebook 身份验证失败!Facebook 返回了无效的用户 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆