Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication failed! Facebook returned an invalid user id #633

Closed
Steeveuk opened this issue Mar 24, 2016 · 8 comments
Closed

Authentication failed! Facebook returned an invalid user id #633

Steeveuk opened this issue Mar 24, 2016 · 8 comments

Comments

@Steeveuk
Copy link

I know this has been posted before, however my issue seems to be different from everyone elses. Basically I have a setup where we have a local, staging and live server and everything connects smoothly on local and staging but live simply keeps getting a fatal exception with this:

Fatal error: Uncaught exception 'Exception' with message 'Authentication failed! Facebook returned an invalid user id.' in /home/dashboard/library/HybridAuth/Hybrid/Auth.php:169 Stack trace: #0 /home/dashboard/library/HybridAuth/Hybrid/Auth.php(55): Hybrid_Auth::initialize('/home/dashb...') #1 /home/dashboard/library/core/UserSocialConnection.class.php(19): Hybrid_Auth->__construct('/home/dashb...') #2 /home/dashboard/public_html/modules/entities/settings/index.php(10): core\UserSocialConnection::get_hybrid_auth(false) #3 {main} thrown in /home/dashboard/library/HybridAuth/Hybrid/Auth.php on line 169

I have changed it from https to http and ensured the base URL is correct. I have also tried multiple configs, permissions and pretty much exhausted every avenue I can think to debug it. I have checked the other threads on here and on Stack overflow to no avail. If anyone has come across this issue before or has any suggestions I am all ears.

Cheers

@lostncg
Copy link

lostncg commented Apr 28, 2016

Weired bug, i cant figure out why

@Steeveuk
Copy link
Author

Steeveuk commented May 3, 2016

I forgot to post the fix which was because i didn't have trustForwarded set to true. It fixed after that. Hope it helps someone in future!

@kocsismate
Copy link

@Steeveuk So you only had to add a trustForwarded" => true to the Facebook config? Do you also use Hybridauth 2.6.0? For me, it always keeps returning 0 as the user id. :(

@deepdev-hk
Copy link

if you Amazon Cloud , you may modify as follow:
./Hybrid/thirdparty/Facebook/base_facebook.php
line 1251:
under "protected function getHttpProtocol() {"
return 'https';
or
if (isset($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'])) { if ($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] === 'https') { return 'https'; } return 'http'; }
and also ./config.php,'base_url' changed http to https
or
"base_url" => ($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] === 'https')?"https://xxx":"http://xx",

hope it helps you,@Steeveuk

@dugwood
Copy link

dugwood commented Aug 31, 2016

@kocsismate can you change, in 2.6.0, the latest return of function getCurrentUrl() in base_facebook.php with:
var_dump($protocol.$parts['host'].$port.$parts['path'].$query); exit;
And see if the url is fine to you?

I've faced the same issue because the getCurrentUrl() wasn't the same as the base_url.

@dugwood
Copy link

dugwood commented Aug 31, 2016

@Steeveuk you should close this bug as you solved it with trustForwarded.

@kocsismate
Copy link

Unfortunately, I no longer have access to the code for which I needed Hybridauth ^^

@Steeveuk Steeveuk closed this as completed Sep 1, 2016
@neo22s
Copy link
Contributor

neo22s commented Jan 20, 2017

in base_facebook.php

  protected function getHttpProtocol() {

    //we are sure is a https request , we use first the Nginx forwarded PROTO OR apache OR cloudflare
        if( (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) AND $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') 
            OR (isset($_SERVER['REQUEST_SCHEME']) AND $_SERVER['REQUEST_SCHEME'] == 'https')
            OR (isset($_SERVER['HTTP_CF_VISITOR']) AND $_SERVER['HTTP_CF_VISITOR'] == '{"scheme":"https"}')
            )
        {   
         
            return 'https';
        }

        return 'http';
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants