【问题标题】:Need to Authorize app everytime - hybridauth laravel localhost每次都需要授权应用程序 - hybridauth laravel localhost
【发布时间】:2014-10-31 07:50:13
【问题描述】:

我已将 hybridauth 与 laravel 集成,并且能够使用 hybridauth 通过 twitter 登录我的应用程序。当我第一次使用 twitter 登录我的应用程序时,我已经授权了我的应用程序。所以,一般来说,下次我不需要授权我的应用程序登录,因为我第一次接受了授权。

但它没有发生。每次我尝试登录 Twitter 时,我的应用程序都必须通过 twitter 授权。

我正在本地主机上尝试这个。我需要在实时服务器中检查它吗?

我正在使用此代码,所有凭据都已设置:

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 Google
        $provider = $socialAuth->authenticate("Twitter");
        // 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();
}));

【问题讨论】:

    标签: twitter laravel localhost hybridauth


    【解决方案1】:

    我找到了解决方案。它不在代码中修复某些东西。这是推特应用程序的设置。为避免此类问题,您应该从应用设置的Permission 部分选择Read and Write 选项而不是Read, Write and Access direct messages 选项。

    如果您选择Read, Write and Access direct messages,那么每当您尝试通过您的 twitter 应用程序登录您的应用程序时,twitter 将始终提示您授权您的应用程序。请参阅下面的图片以获取更清晰的信息。

    希望对您有所帮助。谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      • 2016-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-10
      • 2017-01-10
      相关资源
      最近更新 更多