Setting Website Site URL for facebook php applications issue - php

I am getting this error:
Given URL is not allowed by the Application configuration: One or more of
the given URLs is not allowed by the App's settings. It must match the
Website URL or Canvas URL, or the domain must be a subdomain of one of the
App's domains.
This is how i set my website url:
Why is my url wrong ? Can someone explain me this part ? thx
UPDATE
I tried the following combination:
http://attila-naghi.com/facebook/mytest/
http://attila-naghi.com/facebook/mytest
http://attila-naghi.com/facebook/mytest/index.php
http://www.attila-naghi.com/facebook/mytest/
http://www.attila-naghi.com/facebook/mytest
http://www.attila-naghi.com/facebook/mytest/index.php
but I still get the error.

The error appeared because I did not pass the 'redirect_uri' correctly. I missed the ".com" part. So it should look like this:
$loginUrl = $facebook->getLoginUrl(array (
'scope' => 'publish_actions,read_stream,user_groups,user_about_me,user_interests',
'redirect_uri' => 'http://attila-naghi.com/facebook/mytest/test.php'
));
and
'Given URL is not permitted by the Application configuration: One or more of the given URLs is not allowed by the App's settings. To use this URL you must enable Web OAuth Login in your App's settings.'
error message appeared because it must set the Web OAuth Login to yes and I must add an url for the Valid OAuth redirect URIs field

Related

Facebook Client OAuth settings domain not working with query strings

I'm trying to get the Auth working with Facebook but it keeps on telling me that my redirect URL is not working.
In the Valid OAuth Redirect URIs I have the following
https://localhost
The issue is that, I'm passing some additional query string to my callback, like
https://localhost?uuid=something&service=my_service
When attempting to Auth, I do get the request popup and then I get a redirect URL but then Facebook is telling me that the URL is not allowed.
If I test https://localhost?uuid=something&service=my_service in Facebook's Redirect URI Validator it's telling me it's not valid
How can I add a a URL including a dynamic query string ? I've tried
https://localhost*
But Facebook is telling me this is not a valid URL and won't let me save/add this URL.
#ceejayoz put me on the right track, I will answer my own question, that might help someone else.
Additional data must be passed in a state parameter such as
$data = json_encode($some_std_class);
$pdata = $fb_helper->getPersistentDataHandler();
$pdata->set('state', $data);
$login_url = $fb_helper->getLoginUrl($my_url, $my_permissions);

Codeigniter not handling question mark in Instagram auth redirect

On my website I allow users to link their social media accounts but I have the users authenticate themselves first via the social media API before I add their username.
I am using the Instagram auth api in sandbox mode on my public site (not localhost) and sending the auth request is not an issue but the redirct code from Instagram includes a question mark and I cannot properly parse the URI segments because of this, nothing is showing up in URI segments after the question mark. Below are my settings.
The URL to Instagram is https://www.instagram.com/oauth/authorize/?client_id=7e9b6fabc5bb49e28d24e32a3232380b&redirect_uri=https://www.mywebsite.com/ig/complete&response_type=code.
The redirect URL is https://www.mywebsite.com/ig/complete?code=def1efc5f494483a9286b2136e644999
My route is as follows:
$route['ig/complete?(.+)'] = "callback/ig_handle_response/$1";
My cofig allowed characters are as follows:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-+?';
When I print_r the segments array, the output is Array( [1] => ig [2] => complete ), the URI segments do not contain the code returned from Instagram, looks like anything after the question mark is ignored.
I resolved the issue myself by getting the query_string from the URL.
$code = $this->input->server('QUERY_STRING', TRUE);
Result of $code is "code=83339246a9c74501b9ffafe65aa222ff"

OAuthException: redirect_uri isn't an absolute URI. Check RFC 3986 (Symfony)

I would like to add facebook login option to my website, following this tutorial. I did everything as it is in the tutorial, but I still get this error:
OAuthException: redirect_uri isn't an absolute URI
How is it possible to solve it?
This urls are generated by the facebookOAuthProvider. The website is not on localhost. It runs on a webserver, with https.
This is the relevant code:
// redirect to Facebook
$facebookOAuthProvider = $this->get('app.facebook_provider');
$url = $facebookOAuthProvider->getAuthorizationUrl([
// these are actually the default scopes
'scopes' => ['public_profile', 'email'],
]);
return $this->redirect($url);
It redirects to this url:
https://www.facebook.com/v2.3/dialog/oauth?scopes[0]=public_profile&scopes[1]=email&state=...&scope=public_profile,email&response_type=code&approval_prompt=auto&redirect_uri=/connect/facebook-check&client_id=...
The redirect_uri is indeed not an absolute url. But how is it possible to fix it?
Edit
If I add 'redirect_uri' => [$redir] then the url looks like this:
https://www.facebook.com/v2.3/dialog/oauth?scopes%5B0%5D=public_profile&scopes%5B1%5D=email&scopes%5B2%5D=user_location&redirect_uri%5B0%5D=https%3A%2F%2Fexample.com%2Fconnect%2Ffacebook-check&state=...&scope=public_profile%2Cemail&response_type=code&approval_prompt=auto&client_id=...
I can see the absolute redirect_uri in the generated url, but I still get this error, if I navigate to it
Redir is defined as:
$redir = $this->generateUrl('connect_facebook_check', array(), UrlGeneratorInterface::ABSOLUTE_URL);
Edit2
If I replace [$redir] with $redir then facebook redirects me correctly to /connect/facebook-check with a code, but I get a OAuthException: redirect_uri isn't an absolute URI. Check RFC 3986 there.
I don't know where you got the example code, but certainly not from the linked tutorial.
Facebook authorization is based on the fact that you generate a link to FB, the user goes to the FB and authorizes himself, and then the FB server redirects it back to you (along with whether or not it is authorized).
FB does not guess where to redirect user after login. You need to give him a full path with http(s) and the server name (and if I remember correctly, it is also compatible with that saved in the FB app)
The attached tutorial requires writing a controller with 2 methods (output and return) and corresponding entries in the configuration.
If you use this, then see how you have configured the provider. What is in redirectUri?

OAuth redirect_uri opencart by facebook sdk4

am New to opencart 1.5.5.1 almost did all configuration to make the site have login facebook but no use.
Graph returned an error: Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
I tried to play with url from my side nothing work as checked on internet like add slash after the link and so on
this is the requested site
https://www.facebook.com/v2.4/dialog/oauth?client_id=4444&state=444444&response_type=code&sdk=php-sdk-5.0.0&redirect_uri=http%3A%2F%2Flocalhost%2Fmarkaforyou%2Fwholesale%2F%3Froute%3Dfacebook%2Ffacebook&scope=email%2Cuser_birthday%2Cuser_location%2Cuser_hometown
this url redirected to my site
http://localhost/markaforyou/wholesale/?route=facebook%2Ffacebook&code=AQAB3eJHlzqyopMX0SSxRvChkEmoRE6LtQfghd54634645vb6ybhfgbhfghdfghjfdgh
fgZAZdYe4ivu94IsPf36hrpyfq3K4uyi7dx50&state=69e8f620cdbcdfdf43185fba9b70dc43#=
is there any thing I must need to do in configuration
it was a problem with facebook sdk url clearer
in the FacebookRedirectLoginHelper.php
change the line
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state']);
with
$redirectUrl = substr($redirectUrl, 0, strpos($redirectUrl, '&state'));
and all thing work perfectly

facebook website login with app not doing login

I am just newbie to facebook app and I am doing a simple login in a page from facebook SDK with application id.
I have created the app in facebook. After that my facebook code something looks like this
window.fbAsyncInit = function() {
FB.init({
appId : '619422074760339', // App ID
channelURL : '', // Channel File, not required so leave empty
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : false // parse XFBML
});
};
I have given the appId and secret key. When I tried to login from my localhost using this script it showed me error like
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
So can someone kindly tell me how to solve this issue. Any help and suggestions will be really appreciable. Thanks
The server your app is running on doesn't have the same URL as you have given in the Facebook Apps Setting.
Please check both the URL's , they have to be same.
I had a same problem and I found that there was a mismatch in my "redirect_uri" and "Valid OAuth redirect URIs".
In my code, I had set:
redirect_uri = "http://www.mywebsite.com/validate.php";
But in my Facebook app I had set Valid OAuth redirect URIs (in Settings):
http://website.com/validate.php
All I was missing "www". So I changed Valid OAuth redirect URI in my Facebook app to following:
http://www.website.com/validate.php
I worked like a magic for me.
Hope it will help you.

Categories