Laravel 4 Using HybridAuth: Facebook Provider Issue - php

Laravel noob here.
I'm getting a response "Authentication failed! Facebook returned an invalid user id.". I believe I followed this example correctly.
1. My Website with Facebook Login is set to http://localhost.com
2. HybridAuth config. Base url is set to http://localhost.com/laravel4/public/social/auth/
3. I tried running samples from HybridAuth on the same server, same facebook app id and app secrete; all seems to work okay except when using Laravel framework.
4. Ran updates (Laravel 4 and HybridAuth).
I would appreciate any ideas.

Is there a trailing slash in the base_url variable of your hybridauth config? Removing it fixed the problem on my end.
# app/config/hybridauth.php
return array(
"base_url" => "http://your.site.com/social/auth",
...
);

Related

Laravel Socialite Login, localhost:8000 my laravel project is not running here... Guide please

I am trying to create Socialite Login using laravel. I have wamp server, and my project is running on http://localhost/SocialiteLogin/ <- on this url I am getting laravel logo/demo page.
Project is running well on my browser but when I type this address into (Create OAuth client ID->Authorized JavaScript origins) it gives me this error:
Invalid Origin: URIs must not contain a path or end with "/".
I have seen different videos related to this, their laraval project are running directly on localhost:8000 and they paste the same address into "Authorized JavaScript origins" but when I type this url(localhost:8000) I am getting error:
This site cannot be reached.
Please tell me how can I set my project so that it run on localhost:8000 so that I can use it in Create OAuth client ID.

Facebook App - The domain of this URL isn't included in the app's domains. Why?

When trying to login with a Facebook app, I'm getting the following error:
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
As you can see on the following image:
URL: http://www.facebook-php-test.com
Below is the configuration I have set on my Facebook App.
(Notice: for privacy purposes I changed the values for App ID and App Secret on the image)
The code for this basic sample application is on this GitHub repository:
https://github.com/zeuscronos/facebook-php-test.com
I really don't know why it says that the domain of this URL isn't included in the app's domains when it is actually there.
On the field: App Domains I tried with both domains at the same time:
facebook-php-test.com
www.facebook-php-test.com
but no success.
The generated login URL is as follows:
https://www.facebook.com/v2.10/dialog/oauth?client_id=012345678901234&state=d3758e484d539bebd6505427aaf1fa3b&response_type=code&sdk=php-sdk-5.6.1&redirect_uri=http%3A%2F%2Fwww.facebook-php-test.com%2Ffb-callback.php&scope=email%2Cuser_friends%2Cuser_photos
I configured the domain: facebook-php-test.com as a virtual host on an Apache server.
I have to say that I have worked a lot with the Facebook PHP SDK and this is the first time I'm getting struggle with this. Actually, I got this problem with another big application I was working with then after couple of hours trying to solve the problem I created this dummy application to try to figure out what's the cause of the problem.
I have tried many things with no success.
Any idea on how to solve this?
Thanks.
EDIT 01
Following the suggestion of Mr.Geeker comment I did the following...
Added the product: Facebook Login and configured like below:
Then, finally I could go forward, and I was asked for permissions:
But unfortunately, after granting permissions, I got the following:
Any idea on how to continue from this point?
EDIT 02 - SOLUTION
I ended disabling the option: Use Strict Mode for Redirect URIs under Client OAuth Settings. They say it is strongly recommended has this feature On but I could not get this working with that On.
By the way I also disabled: Client OAuth Login since my app doesn't use it.
Finally, the only feature I have enable under: Client OAuth Settings is: Web OAuth Login.
Facebook now roles some features as plugins. In the left hand side select Products and add product. Then select Facbook Login. Pretty straight forward from there, you'll see all the Oauth options show up.
As originally answered here
On March 2018, facebook updated the API and forced all apps to keep strict mode On.
To make it work, you have to include the full callback url in the Valid OAuth Redirect URIs field. If you redirect to "https://www.example.com/facebook/callback", the full URI must be included (without parameters):
The domain must be set in the App domains and the Website Site URL fields on the basic settings page:
If none of these works and the "Can't Load URL: The domain of this URL isn't included in the app's domains." message keeps showing, check if you have the latest version of the SDK. I could make it work after updating de PHP SDK from version 5.5 to 5.6.2
I'm using PHP 5.5 and I found the bug.
The PHP Facebook API VERSION = '5.5.0', DEFAULT_GRAPH_VERSION = 'v2.9' was adding the URI ?code=XXX in my callback page like this:
mydomainExample.com/callbackFacebook.php ?code=XXXXXXX
and I changed the source code to remove the string after '?'. Now the callback url is only
mydomainExample.com/callbackFacebook.php
The fixed can be done in the file Facebook/Helpers/ FacebookRedirectLoginHelper.php inside the getAccessToken function. I added a 'if' as below in the line 226 and the issue gone:
$redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();
//the next 3 lines was added to avoid the bug (fixed)
if(strripos($redirectUrl, "?")){
$redirectUrl = substr($redirectUrl, 0, strripos($redirectUrl, "?"));
}
// At minimum we need to remove the state param
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state']);

HybridAuth Google+ sign-in error: redirect_uri_mismatch

Trying to implement hybridauth 2.4 on my website,
All codes except config.php are out of the box, but I am having problems with Google+. I have tried everything and am slowly loosing it.
400 Error: redirect_uri_mismatch
Example Url: http://runettv.com/examples/social_hub/
My redirect uri's set in google console:
http://runettv.com/hybridauth
http://runettv.com/hybridauth/
http://runettv.com/hybridauth/examples
http://runettv.com/hybridauth/examples/
I also tried localhost:8080, localhost:8080/ etc.
My base_url is http://runettv.com/hybridauth
Not sure how to troubleshoot.
Has anyone succeeded with this?
The configured redirect_uri and used redirect_uri have to match exactly. Add http://runettv.com/hybridauth?hauth.done=Google to your app configuration and you should be good.

PHP 5.1.6 & Facebook SDK using upgrade.php still not working

I've written a Facebook App for a client which works fine on my own server running PHP5.2
On installing on the clients server we discovered that it was running PHP5.1.6
So no json_de/encode lib.
Client is prevented from upgrading to PHP5.2 by their server vendor and given the hack and state of their website (ancient hacked to death Joomla v1.0) probably risky.
Looking around I found upgradephp (v1.7 I've used).
Which supplies both json_encode & decode
The problem I'm stuck with is that the code is in a perpetual loop trying to get the Facebook user id:
$options = array("scope" => "user_birthday",
"redirect_uri" => "https://apps.facebook.com/".$nameSpace."/");
$loginUrl = $facebook->getLoginUrl($options);
// Get User ID
$user = $facebook->getUser();
if (!$user) {
// Require user to authenticate the app
echo '<script>top.location.href = "' . $loginUrl . '"</script>';
}
This code works great on my own server, just not on the clients.
So I'm left wondering where to start debugging and how?
Any suggestions greatly appreciated!
The answer was simply a configuration issue within the Facebook App panel caused by the client I did the work for.
They had wrongly entered their own web site URL omitting the preceeding "www."
When the app ran it attempted to go to the domain name without the www and was re-directed to the www.domainname. Not only that but the https was dropped for http in the re-direct.
This caused the infinite loop of re-directs as facebook doesn't allow non-https requests.

Login "An Error has Occurred"

I am having an issue when upgrading from Facebook's PHP SDK version 2.1.2 to 3.1.1 in anticipation for the Oct 1, 2011 cutoff. The url appears to have changed:
FROM
https://www.facebook.com/login.php?api_key=MY_KEY
TO
https://www.facebook.com/dialog/oauth?client_id=MY_KEY
Everytime I generate the new URL I keep receiving "An error occurred with Website. Please try again later."
I have searched the wiki/faq on Github page for sdk, but haven't found anything.
Anyone else having this issue?
I had this exact same problem while converting a Connect application. I figured it out! Connect used the application KEY (which is alphanumeric). The new API / oAuth requires the application ID (which is shorter and numeric). An invalid application ID consistently returns this generic error. Hope this helps.
Just in case someone else has this same issue you can also try disabling sandbox mode on your app's config settings on facebook. My scenario was that I could login using facebook but no one else could.

Categories