15

我在 AWS Elastic Beanstalk 上托管我的 PHP Yii 应用程序,因此使用数据库来存储会话。我已经在共享托管环境中使用 Hybridauth 成功实现了 facebook 登录。当我在 Elastic Beanstalk 上托管时,facebook 登录会出现错误:

"You cannot access this page directly"

该 URL 最终为:

http://mydomain.com/hybridauth/default/callback?hauth.start=Facebook&hauth.time=1393106016

我从这里了解到,这与 facebook 回调应用程序但找到不同的会话有关。Endpoint.php 然后抛出错误:

            # Init Hybrid_Auth
        try {
            // Check if Hybrid_Auth session already exist
            if ( ! isset( $_SESSION["HA::CONFIG"] ) ) { 
                header( "HTTP/1.0 404 Not Found" );
                die( "You cannot access this page directly." );
            }

如何确保 facebook 回调到同一会话并使用 hybridauth 成功登录?

4

9 回答 9

5

这是由于 PHP SESSION 名称如果你在 Yii 的配置文件中更改了会话名称。然后你必须在functoin的开始使用add this session_name('samar_v4');in fileprotected/modules/user/vendors/hybridauth/Hybrid/Endpoint.phpauthInit

于 2015-11-23T12:03:02.317 回答
3

Check your Facebook application's redirect URL. Facebook doesn't allow multiple redirect URLs. So each time you change your hosting/domain/address, you'll have to reconfigure the Facebook application's redirect URL or use a different set of credential.

Also your redirect URL should be something like this: http://mydomain.com/hybridauth/?hauth.done=Facebook

于 2014-03-03T19:04:32.153 回答
2

这也对我有用:

"base_url" => " https://example.com/inc/hybridauth/ ",

我把它改成

"base_url" => "https://".$_SERVER['HTTP_HOST']."/inc/hybridauth/",

于 2015-03-16T13:39:30.553 回答
1

对于其他在这个问题上苦苦挣扎的人,它与 www 域注册问题无关,我的问题与无法写入 php 会话目录有关。不确定如何或何时更改,但如果您无法写入 /var/lib/php/5.5/session,hybridauth 将无法工作。

于 2015-02-27T21:12:28.790 回答
1

对我来说,它适用于主域,但不适用于子域。我发现是 config.php 中的 base_url 导致了错误。

代替

"base_url" => "https://mydomain.com/inc/hybridauth/",

我把它改成

"base_url" => "https://".$_SERVER['HTTP_HOST']."/inc/hybridauth/",

现在它可以在我放置的任何地方工作。

于 2014-09-14T06:43:35.433 回答
1

根据其他答案,我认为这是一个会话问题,也许会话是在错误的域下启动的,然后无法在另一个域下重新获取。

我通过从我的开发 Apache 配置中删除各种 ServerAlias 设置解决了这个问题。

这“导致”了错误:

ServerName mydomain.com.au.localhost
ServerAlias www.mydomain.com.au.localhost
ServerAlias localhost.mydomain.com.au        # << using this one

这修复了错误:

#ServerName mydomain.com.au.localhost
#ServerAlias www.mydomain.com.au.localhost
ServerName localhost.mydomain.com.au        # << using this one

apachectl restart

(我通常使用 mydomain.com.au.localhost,所以我将它们留待以后使用。)

于 2016-06-16T01:18:50.400 回答
1

我在使用 Hybrid Auth 2.8 时遇到了同样的问题。它与我们设置的自定义会话处理程序有关session_set_save_handler()。Hybrid Auth 使用标准 PHP 会话,因此在重定向并打开新会话后,Hybrid Auth 开始使用标准 PHP 文件会话而不是您的自定义会话处理程序。这会导致我们会话中的配置数据丢失并收到此错误消息。

我通过在顶部添加我们自己的自定义会话处理程序解决了这个问题(与和hybridauth/index.php位于相同的目录中)。这会强制 Hybrid Auth 使用您的自定义会话处理程序。config.phplive.php

于 2017-02-09T10:45:36.337 回答
0

我使用会话 cookie 上的域名解决了我的特定 HybridAuth“您无法直接访问此页面”错误。我的应用程序存在于子域中,我将重定向设计为指向 socialize.sub.domain.tld,并且 cookie 没有到达 _Endpoint。

将会话域更改为 .domain.tld 解决了它。- 希望这可以帮助 :)

于 2016-08-23T00:40:17.147 回答
0

我发现这个问题似乎无法解决。我正在放弃,那时我的直觉引导我进行测试,瞧一切正常。

对于有同样问题的人有一个疑问:调用API的文件是在同一个目录下吗?

  仅当我将文件与 config.php 文件放在同一文件夹中时,我才工作。在那里尝试并告诉我它是否有效!

给大家一个拥抱和问候!

于 2016-05-26T21:36:11.463 回答