alixandru / q2a-open-login

Question2Answer Open Login plugin
62 stars 44 forks source link

You cannot access this page directly. #70

Closed MoonWatcher582 closed 5 years ago

MoonWatcher582 commented 8 years ago

Hi @alixandru,

I've enabled Google login using open-login and provided the ID and secret, but when I try click on "Login with Google" button I'm taken to a blank page which reads "You cannot access this page directly.

Any thoughts on why this happens?

Thanks

alixandru commented 8 years ago

It might be that something changed at Google side and the plugin code became obsolete. I have updated the Hybridauth library used by the plugin to the latest version. This should solve this and a number of other issues.

Please update your copy and try again.

MoonWatcher582 commented 8 years ago

It's throwing an exception instead of dying now, and the complaint seems to be that it can't find the Hybrid_Storage config.

if (!$storage->config("CONFIG")) {
    throw new Hybrid_Exception("You cannot access this page directly.");
}
alixandru commented 8 years ago

What does the ERROR_LOG say?

MoonWatcher582 commented 8 years ago
PHP Fatal error:  Uncaught exception 'Hybrid_Exception' with message 'You cannot access this page directly.' in /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php:211
Stack trace:
#0 /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php(117): Hybrid_Endpoint->authInit()
#1 /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php(51): Hybrid_Endpoint->processAuthStart()
#2 /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php(72): Hybrid_Endpoint->__construct(NULL)
#3 /var/www/html/qa-include/qa-base.php(595) : eval()'d code(142): Hybrid_Endpoint::process()
#4 /var/www/html/qa-include/qa-base.php(595) : eval()'d code(44): qa_layer_3_from_qa_open_layer_php->process_login()
#5 /var/www/html/qa-include/qa-page.php(379): qa_layer_3_from_qa_open_layer_php->doctype()
#6 /var/www/html/qa-include/qa-page.php(830): qa_output_content(Array)
#7 /var/www/html/qa-include/qa-index.php(183): require('/var/www/html/q...')
#8 /var/www/html/index.php(27): require('/var/www/html/q...')
#9 {main}

Next exception 'Hybrid_Exception' with message in /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php on line 217
alixandru commented 8 years ago

This doesn't tell me much... any other errors before that? Or warnings? Also, the blank page you are redirected to, can you tell me what URL parameters it has? Not necessarily the value, but parameter names.

Alternatively, try using Google Plus.

MoonWatcher582 commented 8 years ago

I commented out the if branch above and ran it once, and now instead of the blank page I'm being directed to

https://accounts.google.com/o/oauth2/auth?client_id=<clientid>&redirect_uri=http%3A%2F%2F162.243.192.10%2F%2F%3Fhauth.done%3DGoogle&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.profile.emails.read+https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F&access_type=offline

Which brings me instead to a Google error page which tells me Invalid parameter value for redirect_uri: Raw IP addresses not allowed: http://162.243.192.10//?hauth.done=Google. This error is on my side, I assume. And since the line after the if branch I commented out appears to initialize the config, I'm guessing that step must have been skipped at some point prior?

alixandru commented 8 years ago

Yeah, not sure why initialization did not took place in your case - it should be done prior, then store the config on the session and later be able to get it, when calling process(). Maybe it has to do with your Q2A config - I can't tell. If possible, you can try using a virtual host (defined in your hosts file) - make sure you also set it in your Q2A config.

Hitman666 commented 8 years ago

I've got the same issue just today. I found that when I click the Google login button it redirects me to the IP and just stops there. If I however change the IP to the actual domain name it goes through.

However, again, once I login via google I'm returned to the initial page and nothing happens. My error logs look like this:

[Tue Aug 16 07:40:37.146368 2016] [:error] [pid 11827] [client 93.139.199.130:49381] PHP Fatal error: Uncaught exception 'Hybrid_Exception' with message 'You cannot access this page directly.' in /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php:211\nStack trace:\n#0 /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php(117): Hybrid_Endpoint->authInit()\n#1 /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php(51): Hybrid_Endpoint->processAuthStart()\n#2 /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php(72): Hybrid_Endpoint->__construct(NULL)\n#3 /var/www/html/qa-plugin/open-login/qa-open-login.php(137): Hybrid_Endpoint::process()\n#4 /var/www/html/qa-include/qa-page.php(102): qa_open_login->check_login()\n#5 /var/www/html/qa-include/qa-page.php(817): qa_check_login_modules()\n#6 /var/www/html/qa-include/qa-index.php(183): require('/var/www/html/q...')\n#7 /var/www/html/index.php(27): require('/var/www/html/q...')\n#8 {main}\n\nNext exception 'Hybrid_Exception' with message 'Endpoint: Error while trying to init Hybrid_Auth: You cannot access this page directly.' in /var/www/html/qa-plugin/open-login/Hybrid/En in /var/www/html/qa-plugin/open-login/Hybrid/Endpoint.php on line 217, referer: http://mysite.com/

Hitman666 commented 8 years ago

I just want to update you on how I got it working in my case. Unbelievable as it may sound, but I had to enable Google+ API in my Google developer console for this project and voila, it worked.

miguelpragier commented 6 years ago

Here I made two things at the same time, but I'm not sure which one solved. Check:

My beliefs:

If it's about the garbage collector, I really have to study SessionGC, because it makes no sense. If it's about the $_REQUEST checks, it's a difference between versions I'm using in my servers. Please, share if some of these fixes worked for your environment.

alixandru commented 5 years ago

The Auth library has been updated to the latest version. Please check if the issue persists with this version. Also, check you config at both Q2A and Google console side. Closing for now.