Oauth Facebook Social Login

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Oauth Facebook Social Login

Post by WelshPaul »

I have been using the oauth Facebook social login on my website for a long time, last night I noticed it doesn't work anymore? Not sure if it's due to me upgrading to phpBB 3.2 or because Facebook has updated it's API?

If I enter the following Valid OAuth redirect URIs:

Code: Select all

https://www.mydomain.com/ucp.php?i=ucp_auth_link&mode=auth_link&link=1&oauth_service=facebook
I get the following error:

Code: Select all

Fatal error: Uncaught OAuth\Common\Http\Exception\TokenResponseException: Methods with the same name as their class will not be constructors in a future version of PHP; bitfield has a deprecated constructor in /var/sites/u/mydomain.com/public_html/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php:73 Stack trace: #0 /var/sites/u/mydomain.com/public_html/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php(183): OAuth\Common\Http\Client\StreamClient->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), NULL, Array, 'GET') #1 /var/sites/u/mydomain.com/public_html/phpbb/auth/provider/oauth/service/facebook.php(72): OAuth\OAuth2\Service\AbstractService->request('/me') #2 /var/sites/u/mydomain.com/public_html/phpbb/auth/provider/oauth/oauth.php(557): phpbb\auth\provider\oauth\service\facebook->perform_auth_login() #3 /var/sites/u/mydomain.com/public_html/phpbb/auth/provider/oauth/oauth.php(487): phpbb\auth\provider\oauth\oauth->link_account_auth_link(Array, 'auth.provider.o in /var/sites/u/mydomain.com/public_html/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php on line 73
If I don't enter anything in the Valid OAuth redirect URIs field, I am forwarded to the Facebook site where I get the following error:
URL blocked: This redirect failed because the redirect URI is not white-listed in the app's client OAuth settings. Make sure that the client and web OAuth logins are on and add all your app domains as valid OAuth redirect URIs.
Using phpBB 3.2, php 7.1 but get the same results using php 5.6 too.
User avatar
JimA
Former Team Member
Posts: 7833
Joined: Thu Jul 31, 2008 5:54 am
Location: The Netherlands
Name: Jim Mossing Holsteyn
Contact:

Re: Oauth Facebook Social Login

Post by JimA »

I've just tested this on our test board, and this seems to be happening there as well. Could you please report this issue to our Bug Tracker so it will be brought to the attention of our developers?
Jim Mossing Holsteyn - Former Community Team Leader
Knowledge Base | Documentation | Board rules

If you're having any questions about the rules/customs of this website, feel free to drop me a PM.
User avatar
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: Oauth Facebook Social Login

Post by WelshPaul »

JimA wrote: Sun Apr 02, 2017 10:33 am I've just tested this on our test board, and this seems to be happening there as well. Could you please report this issue to our Bug Tracker so it will be brought to the attention of our developers?
Thank you for the confirmation, have submitted this to the bug tracker.
User avatar
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: Oauth Facebook Social Login

Post by WelshPaul »

Fix - Open vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php...

Find:

Code: Select all

        // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ?
Replace with:

Code: Select all

        $data = @json_decode($responseBody, true);
        // Facebook gives us a query string on old api (v2.0)
        if (!$data) {
            parse_str($responseBody, $data);
        }
Valid OAuth redirect URIs:

Code: Select all

https://www.domain.com/ucp.php?i=ucp_auth_link&mode=auth_link&link=1&oauth_service=facebook
https://domain.com/ucp.php?i=ucp_auth_link&mode=auth_link&link=1&oauth_service=facebook
http://www.domain.com/ucp.php?i=ucp_auth_link&mode=auth_link&link=1&oauth_service=facebook
http://domain.com/ucp.php?i=ucp_auth_link&mode=auth_link&link=1&oauth_service=facebook
https://www.domain.com/ucp.php?mode=login&login=external&oauth_service=facebook
https://domains.com/ucp.php?mode=login&login=external&oauth_service=facebook
http://www.domain.com/ucp.php?mode=login&login=external&oauth_service=facebook
http://domain.com/ucp.php?mode=login&login=external&oauth_service=facebook
Replace domain.com with your own domain URL!
User avatar
Dr.Death
Registered User
Posts: 400
Joined: Fri Apr 25, 2003 10:04 am
Location: Germany
Contact:

Re: Oauth Facebook Social Login

Post by Dr.Death »

Ah, the first find and replace was not clear enough:

FIND:

Code: Select all

        // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ?
        parse_str($responseBody, $data);
REPLACE WITH:

Code: Select all

        $data = @json_decode($responseBody, true);
        // Facebook gives us a query string on old api (v2.0)
        if (!$data) {
            parse_str($responseBody, $data);
        }
works.... thx for the "fix".
Doc.
obeliksz
Registered User
Posts: 1
Joined: Mon Jun 12, 2017 7:46 am

Re: Oauth Facebook Social Login

Post by obeliksz »

Glad to see a fix, was waiting for it from march already... :)

Before when it did work it redirected the user to facebook to create an account/login based on their facebook user, now when I click the facebook icon with the link: http://domain.com/phpbb/ucp.php?mode=lo ... e=facebook

I just get a message with the button to register and inputs to login:
Link or register your account on an external service with your board account

You have attempted to login with an external service that is not yet connected to an account on this board. You must now either link this account to an existing account or create a new account.

What is wrong?
Amilo
Registered User
Posts: 3
Joined: Sat Jan 08, 2011 11:19 am

Re: Oauth Facebook Social Login

Post by Amilo »

Hello all,
please I have got same problem as obeliksz. Running phpBB 3.2.1

Please help, thanks :)
User avatar
WelshPaul
Registered User
Posts: 420
Joined: Tue Aug 19, 2014 2:09 pm

Re: Oauth Facebook Social Login

Post by WelshPaul »

The Facebook account that you have signed into isn't linked to a forum account. When you get that message, log into your forum as normal and the Facebook account will be linked to it and in future you can log in using your Facebook account.

Basically, you must first link a social account to your forum account. Only then can you log in only using your social login!
Raintek
Registered User
Posts: 37
Joined: Wed Dec 14, 2011 11:54 am

Re: Oauth Facebook Social Login

Post by Raintek »

I've got problem with Oauth too... did everything like you wrote + configured facebook app like in this topic:
viewtopic.php?f=556&t=2416436

And I am still getting this error:

Code: Select all

Fatal error: Uncaught exception 'OAuth\Common\Http\Exception\TokenResponseException' with message 'Failed to request resource. HTTP Code: HTTP/1.1 400 Bad Request' in /domains/thehunter.pl/public_html/forum/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php:68 Stack trace: #0 /domains/thehunter.pl/public_html/forum/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php(125): OAuth\Common\Http\Client\StreamClient->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), Array, Array) #1 /domains/thehunter.pl/public_html/forum/phpbb/auth/provider/oauth/service/facebook.php(69): OAuth\OAuth2\Service\AbstractService->requestAccessToken('AQBwsavG9hKCmLx...') #2 /domains/thehunter.pl/public_html/forum/phpbb/auth/provider/oauth/oauth.php(557): phpbb\auth\provider\oauth\service\facebook->perform_auth_login() #3 /domains/thehunter.pl/public_html/forum/phpbb/auth/provider/oauth/oauth.php(487): phpbb\auth\provider\oauth\oauth->link_account_auth_link(Array, 'auth.provider.o...') #4 /domains/thehunter.pl/pu in /domains/thehunter.pl/public_html/forum/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php on line 68
Any idea how to bring it alive?
Post Reply

Return to “[3.2.x] Support Forum”