How to Test Facebook Connect Locally - facebook

I use ASP .NET and Facebook Connect APIs. but when I run the app and press Connect button it's return to the Website not to the test local server which is (http://localhost:xxxx/test.aspx)
So how I can test Facebook locally (i.e How I can change the callback url) ?

It's simple enough when you find out.
Open /etc/hosts (unix) or C:\WINDOWS\system32\drivers\etc\hosts.
If your domain is foo.com, then add this line:
127.0.0.1 local.foo.com
When you are testing, open local.foo.com in your browser and it should work.

Edit your app at www.facebook.com/developers/ and set the "Site URL" to "http://localhost/myapppath".
When done - change it back.

Facebook has added test versions feature.
First, add a test version of your application: Create Test App
Then, change the Site URL to "http://localhost" under Website, and press Save Changes
That's all, but be careful: App ID and App Secret keys are different for the application and its test versions!

I suggest creating a test app (for dev environment only) on https://developers.facebook.com/apps and set: Website with Facebook Login property to your localhost:[port] settings.
this option will work fine with no need to change hosts.
remember to change the appId back to your production app once you go live.
Edit - in the latest fb version you'll find it under the settings tab.

You don't have to do anything difficult!
Facebook → Settings → Basic: write "localhost" in the "App
Domains" field then click on "+Add Platform" choose "Web Site".
After that, in the "Site Url" field write your localhost url (e.g.: http://localhost:1337/something).
This will allow you to test your facebook plugins locally.

Facebook seemingly randomly disables the ability to set localhost as a domain on your facebook app. I found the easiest work around was to tunnel my localhost to the web. This can be done for free using http://progrium.com/localtunnel/ or with a custom url (easier since you don't have to change url everytime in facebook) https://showoff.io

I couldn't use the other solutions... What worked for me was installing LocalTunnel.net (https://github.com/danielrmz/localtunnel-net-client), and then using the resulting url on Facebook.

Looks like FB just changed the app dev page again and added a feature called "Server IP Whitelist".
Go to your app and Select Settings -> Advanced Tab
Get your public IP (google will tell you if you google "Whats My IP")
Add your public IP to the Server IP Whitelist and click Save Changes at the bottom

go to canvas page..
view it in browser.. copy the address bar text.
now go to your facebook app
go to edit settings
in website, in site url paste that address
in facebook integration , again paste the that address in canvas url
and also the same code wherever you require canvas url or redirect url..
hope it will help..

LAST TESTED 2021/06/07
Just a few notes to complement the excellent answer of #Erdal_G with my successful experience:
Apparently, HTTPS is needed even in the local environment (I used the library https-localhost).
[I don't know if this is mandatory] create a test app from the main app (https://developers.facebook.com/docs/development/build-and-test/test-apps/)
Set the redirect OAuth URI to https://localhost:<MY_PORT>/auth/ and update also all other URIs in .../instagram-basic-display/basic-display/ settings accordingly.
Finally, don't forget to use the client-id (aka app-id) and app-secret of the test app in the requests, which are different than the parent app

Create 2 apps and
In /initializers/env_variables.rb
if Rails.env == 'development'
ENV['FB_APP_ID'] = "HERE"
ENV["FB_SECRET"] = "HERE"
else
ENV['FB_APP_ID'] = "HERE"
ENV["FB_SECRET"] = "HERE"
end

Related

Facebook OAuth "The domain of this URL isn't included in the app's domain"

Let me first start with saying I've searched for an answer to this question for quite some time...
I'm trying to setup Facebook OAuth to work with my application that is being developed locally on my machine. Everything was working perfect with Facebook authorization UNTIL I moved from using localhost to another domain name (still local to my machine.) Now 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.
My hosts file contains 127.0.0.1 domain.dev (works perfect)
My redirect in my app (using Socialite) is http://domain.dev/auth/facebook/callback
In my Facebook App Settings...
my App Domain is domain.dev
my Site URL is http://domain.dev/
my Valid OAuth redirect URIs is
http://domain.dev/auth/facebook/callback
The URL at the time of the error message is..
https://www.facebook.com/v2.5/dialog/oauth?client_id=XXXXXXXXXXXXXXX&redirect_uri=http%3A%2F%2Fdomain.dev%2Fauth%2Ffacebook%2Fcallback&scope=email&response_type=code&state=0ztcKhmWwFLtj72TWE8uOKTcf65JmePtG95MZLDD
I'm at a loss of what the problem is...
Screen Shot 1
Screen Shot 2
In case someone comes across this and is looking for these settings (like I was)
You have to
On the left hand side, click "+Add Product" and select "Facebook Login" (it was at
the top for me)
See the new settings available on the left hand side
You will now have these OAuth settings on that "Product Settings"
Additional Info: Make sure to add the Callback URL like http://localhost:3000 to the Valid OAuth redirect URIs field on the settings page of Facebook Login
This usually happens if you have entered the wrong details when you created the App in Facebook. Or have you changed a URL's of an existing App?
Can you please recheck the settings of your APP in this page?
https://developers.facebook.com/apps
Select the correct App and click in the edit button;
Check the URLs & paths are correctly entered and are pointing to the site where you have installed Ultimate Facebook plugin.
I had the same problem. I solved it by adding my OAuth redirect URI as a argument to the getAccessToken function call:
$redirectLoginHelper->getAccessToken("https://www.example.com/myfacebookcallback")
If no argument is sent into that function the SDK generates the redirect URI by itself which should work but in my case it didn't.
Hope this helps someone.
Make sure your app is public.
Click on + Add product
Now go to products => Facebook Login
Now do the following:
Valid OAuth redirect URIs : example.com/
Deauthorize Callback URL : https://example.com/facebookapp
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.
I had this issue today, I find the Facebook documentation and SDK disrespectful and arogant towards other developers to say the least.
Besides having the "app domains" in two different locations without much information (3 if you add a "web" platform), you also need to go to app products / facebook login / settings and add your redirect URL under Valid OAuth Redirect URIs
The error says NOTHING about the oauth settings.
Here's what I did to solve this issue:
Basically:
1) Enable "Embedded Browser OAuth Login"
2) Disable "Use Strict Mode for Redirect URIs" and enter a redirect
URI like the way I did.
3) Leave all the rest of the options as they are.
4) Save your changes.
5) Enjoy :)
Facebook has recently disabled the toggle button for 'Use Strict Mode for Redirect URIs', so you need to add exact URI what's being called when you hit login button. For my case it was as shown in screenshot.
It solved the issue for me :)
I had the same problem, and it came from a wrong client_id / Facebook App ID.
Did you switch your Facebook app to "public" or "online ? When you do so, Facebook creates a new app with a new App ID.
You can compare the "client_id" parameter value in the url with the one in your Facebook dashboard.
In my case, things i had to do is only enabling the Embedded Browser OAuth Login
As of 2017-10.
Solution that solved my issue.
Currently that FB renders this surprise.
...app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on...
The settings to adjust are located here https://developers.facebook.com/apps/[your_app_itentifier]/fb-login/.
The trailing slash is important. They must match in your app code and in FB admin settings. So this is a config somewhere in your code (see below how to get any domain name for a dev app):
{
callbackURL: `http://my_local_app.com:3000/callback/`, // trailing slash
}
and here
To get any domain name for an app on a local Windows machine, edit host file. Custom names are good in order to get rid of all those localhost:8080, 0.0.0.0:30303, 127.0.0.0:8000, so forth. Because some third party services like FB sometimes fail to let you use 127.0.0.0 names.
On Windows 10 hosts file is here:
C:\Windows\System32\drivers\etc\hosts
Backup initial file, create a copy with different name (Doesn't work in native Windows CMD. I use Git for Windows, it has many Unix commands)
$ cp hosts hosts.bak
Add this in hosts
127.0.0.1 myfbapp.com # you can access it in a browser http://myfbapp.com:3000
127.0.0.1 www.myotherapp.io # In a browser http://www.myotherapp.io:2020
In order to get rid of port part :3000 set up NGINX, for example.
The way I fixed it: I went to the Valid OAuth Redirect URIs textbox and set the exact URL, not just the domain:
before: https://my-website.com
after: https://my-website.com/facebookoauth/facebooklogin
(the url may be different in your case, check it in the address bar of the browser).
This was caused by the setting Use Strict Mode for Redirect URIs, which was locked in the Yes position.
Most of the time its happen with not insert proper valid OAuth redirect URL in the product section of the FB dashboard.I suggest follow my bellow steps
01.Check the basic setting of the app is okay with bellow picture with you
02.check whether you have add a product
If not you can easily add log in product by clicking + sine as I show in the bellow.
If Yes just got to inside of the product setting.
03.The check whether you have provide valid OAuth redirect URL
Its simple mean what should after login.It is not other than that your call back URl.You can see in my bellow picture I have added several redirect URLs.
have any problem further Watch my video-- >
https://www.youtube.com/watch?v=mdhubrzV5y8&t=3s
Click here Code Project!
Its Code project example. Its working to me
I had the same problem,
I just added the link of my local adress http://localhost/Facebook%20Login%20Test.html to Site URL in my application setting https://developers.facebook.com/apps.
Now it works fine :) I hope this was useful ;)
Nothing really worked for me, until I updated the SDK version I was using. I started with 5.0. Not even 5.4.0 would not work either. When I updated to 5.6.2, it worked flawlessly, despite there being nothing in the changelogs that was relevant!
This option should be enabled in portal:
In case this helps anyone else, this started happening for me on an older site when "Valid OAuth Redirect URIs" became mandatory. The site was still using the V4 PHP SDK and the problem was resolved for me by upgrading to the V5 SDK.
In the App domain section, you are writing your app domain but you also need to add your login domain i.e. the name of html page where you ask user to login. In my case, I was testing it on localhost and the login route was localhost/login, If I only put http://localhost.com in App domain section, I get this error. But after adding http://localhost/login.com, the error was fixed.
and also the App settings has changed in newer version of SDK, in which there is no option for OAuth redirect route. You've to assign the redirect route directly from server side, after successfully getting OAuth token.
This worked for me:
Here's the main thing to understand: Facebook will always check for the "WWW" domain. So make sure www.your_domain.dev is working on your browser first.
It is possible that if you have multiple virtual hosts on your local server, some other virtual host overrides "www.your_domain.dev". So please check that.
Apache will pick the FIRST definition of domain (or ports, or something in these terms - I'm no expert on this, but learned by mistakes).
An easy quick fix for this virtual host overriding is to put "www.your_domain.dev virtual host definition on the very top of the file "httpd-vhosts.conf".
Go to "/apache/conf/https-vhosts.conf" and put this on the very top of the file:
<VirtualHost *:80>
<Directory "C:/your_app_folder_path/">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName your_domain.dev
ServerAlias your_domain.dev
DocumentRoot "C:/your_app_folder_path/"
</VirtualHost>
###### FOR SSL #####
<VirtualHost *:443>
DocumentRoot "C:/your_app_folder_path/"
ServerName your_domain.dev
ServerAlias www.your_domain.dev
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
<Directory "C:/your_app_folder_path/">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Next: If you are using Windows system, edit your "hosts" file in "C:\Windows\System32\drivers\etc" by adding two lines:
127.0.0.1 your_domain.dev
127.0.0.1 www.your_domain.dev
Next: Restart your Apache server and everything should work now.
I hope this will help you and save your time.
I wasted almost a whole day searching around the web and was pulling my hair out and couldn't find anything helpful until I found this.
The problem, and the answers, keep changing as FB tightens up the login procedure. Today, I started getting this horror message "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."
The answer was: now FB wants the full redirect uri. So for me, where it used to be just https://www.example.com it now wants https://www.example.com/auth/facebook/callback. This has to go in the "Valid OAuth redirect URIs" field (Developer/Facebook login->setting)
Facebook Login -> Settings -> Valid OAuth redirect URIs -> insert the domains of your redirect url, remember you should add 'https' or http.
eg: if your redirect url is https://xxx.xxx.com/path/callback.do, you only need to enter https://xxx.xxx.com/, it's ok for me.
I had the same problem.....the issu is in the version PHP SDK 5.6.2 and the fix was editing the following file:
facebook\src\Facebook\Helpers\FacebookRedirectLoginHelper.php
change this line
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl,['state','code']);
to
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl,['state','code','enforce_https']);
This same Facebook error happened to me in the Production environment. The reason was I had 2 apps registered with Facebook (Local, Production) but I hardcoded the Local app ID into the source code and forgot to switch it out for the Production app ID before deployment.
Best practice dictates you shouldn't have the app ID hardcoded into the source code but if you do, do not mismatch your various Facebook app IDs like I mistakenly did.
Using my own local server.
Simply adding http://localhost/my-site as a URL in:
https://developers.facebook.com/apps/YOUR-APP-ID/fb-login/
worked for me.
first step:
use all https://example.in or ssl certificate URL ,
dont use http://example.in
second step:
faceboook application setting->basic setting->add your domain or subdomain
third step:
faceboook application login setting->Valid OAuth Redirect URIs->add your all redirect url after login
fourth step:
faceboook application setting->advance setting->Domain Manager->add your domain name
do all this step then use your application id, application version ,app secret for setup
on Magento 2 Social Login extension, you have to copy Valid OAuth redirect URIs from the panel and add the link to Valid OAuth Redirect URIs field in Client OAuth Settings page at developers.facebook.com
If your game has no server/site (e.g. if you develop for Gameroom like me) - add "https://apps.facebook.com/xxxxxxxxxxxxxxxxx" (put your app ID instead of "xxxxxxxxxxxx") to "Valid OAuth Redirect URIs".
in my case, i solved this issue by adding the full URL and not only the domain as facebook ask. i hope that they will rename it for more clarification.
so the Valid OAuth Redirect URIs should be like so:
Before: https://www.mobile-battles.com
After: https://www.mobile-battles.com/register
The Meta for Developers interface currently provides two places where you can enter the domains for your app: the Basic settings under "App domains", and the Advanced settings under "Domain Manager". The SDK might not recognize your domain if it is listed in just the Domain Manager.
If you are using AWS Cognito then add the URL https://<your-user-pool-domain>/oauth2/idpresponse to the Valid OAuth Redirect URIs in Facebook Login -> Settings

Facebook App : This must be derived from Canvas URL, Secure Canvas URL

Hi I wan't to create a facebook app to use it for the auth in my new site locally installed(my machine),but from yesterday I don't succeed to install it and use it, all time I have this very strange error when I wan't write a domain in the "App Domains" :
This must be derived from Canvas URL, Secure Canvas URL, Site URL, Mobile Site URL, Page Tab URL or Secure Page Tab URL. Check and correct the following domains
the domain of my application is http://localhost/project/app_dev.php/ it dosn't work I change it by a real url such as : http://www.exemple.com/,but I had the same error,and just I notice that I see this error when I create an app with new look of facebook (yesterday)...
In my case the problem was I hadn't completed the "+ Add Platform > Website" section. Once I did that the contents of App Domains became valid and the error went away.
I had this same problem yesterday, the stackoverflow answers that helped me the most were
Make local development work with Facebook/Google APIs and Canvas URL / Secure Canvas URL error message ( Also checkout How to handle OmniAuth callbacks in multiple environments?)
The Facebook developer UI has changed a bit. I'm writing this answer to consolidate all the info that helped me.
1. Make local.host Point to Your Computer
First thing you need to do is (as answered in the first link), facebook won't take localhost as a valid callback site, because it confuses localhost with a top level domain (com org etc.) in other words there is not dot . in your domain name. So change your /etc/hosts to add the entry
127.0.0.1 local.host
Now youcan access your app at http://local.host/... (this will take effect as soon as you save /etc/hosts file, no need to restart anything)
2. Add local.host as the Site URL on the facebook Dev Console
The second thing you need to do is add local.host as the site url on the facebook page
Now don't use your production app. Add a dummy app on your https://developers.facebook.com account Because your production app will have to set the site URL to your production URL and not local.host
Configure the dummy app as shown in the screenshot. But that website section(shown in the screenshot) won't be visible on the Basic settings page from the beginning.
First you will have to click + Add Platform button at the bottom, and select Website.
Notice I added http://local.host:3000/. That's where my ruby server runs in dev mode.
Also, be sure to use App Id and App Secret for the dummy app when running your webapp in dev mode.
HTH.
My problem was that logging in with facebook wasn't working for my app.
It turned out that I just needed to fill in the "Valid OAuth redirect URIs" field on the "Advanced" tab.
e.g. http://example.com/auth/google/callback
I'd a similar problem, Facebook have changed now on left pane file login (After selecting you app from top left corner) -> Valid OAuth redirect URIs
If you work on desktop app like WPF or winforms and use a WebBrowser Control to log in with the Facebook SDK.
You have to set to yes the Embedded Browser OAuth Login in Advance Tab of your facebook apps setting.
hope I help
Chose "Add platform" at the bottom and give your localhost url. "http://localhost:port/".
After this step. Facebook allows you to add localhost:port as your domain url.
After these 2 steps you can test "login with facebook" without any trouble.

Given URL is not allowed by the Application configuration

I am trying to create facebook sign-in page according to this tutorial. I only changed the two lines
appId : '370675846382420', // App ID
channelUrl : '//http://bp.php5.cz/channel.html', // Channel File
and I get the following 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.
What might be the problem?
The problem is that whatever url you are currently hosting your app is not setup in your Application configuration. Go to your app settings and ensure the urls are matching.
Updated
Steps:
Go to 'Basic' settings for your app
Select 'Add Platform'
Select 'Website'
Put your website URL under 'Site URL'
This can also happen when the redirect_uri submitted with the https://www.facebook.com/dialog/oauth request is not present in the list of Valid OAuth redirect URIs under:
Settings >> Advanced >> Security
After much trial and error, when I added the redirect_uri that I was using (https://www.facebook.com/connect/login_success.html in my case), I suddenly got to the step past this error.
The above answers are right, but you have to make sure you input right URL.
You have to go to: https://developers.facebook.com/apps
Select your app
Click settings
Enter contact email (for publishing)
Click on +add platform
Add your platform (probably WEB)
Enter site URL
You have two choices to enter: http://www.example.com or http://example.com
Your app will work only with one of them. In order to make sure your visitors will use your desired url, use .htaccess on your domain.
Here's good tutorial on that: http://eppand.com/redirect-www-to-non-www-with-htaccess-file/
Enjoy!
Go to your application, settings (basic tab) and add platform (website). Type your site url and done.
Do the above work of adding the site and then the url.
I think the layout of facebook has changed little bit so also do the below things.
- Go to developers.facebook.com -> your app
- Go to Settings->Advanced.
- Under the Security->Valid OAuth redirect URIs, insert all the uri's your app is supposed to redirect to. For example (
http://localhost:1443/cas/login, https://localhost:2443/cas/login, http://rajanpupa.com/cas/login
etc)
- That should do it.
I faced the same issue. I had entered http://www.example.com in the App settings. When anybody accessed my website using the full URL, Facebook Login worked fine. But if somebody typed in the URL without www in the browser, Facebook Login failed with this error message. When I changed the App Setting to http://example.com everything started working fine.
Go to https://developers.facebook.com/apps and open the app you have created. open setting tab and add platform and insert site url where you want to share facebook button .Its done.
The other answers here are excellent and accurate. In the interest of adding to the list of things to try:
Double and triple-check that your app is using the right application ID and secret key. In my case, after trying many other things, I checked the application ID and secret key and found that I was using our production settings on our development system. Doh!
Using the correct application ID and secret key fixed the problem.
My Problem Solved by
public static final String REDIRECT_URI = "http://google.com";
it will redirect to Url after ur Login into Facebook.and also you have to reach
url : https://developers.facebook.com -> My App -> (Select your app) ->Settings ->Advanced Setting -> Valid OAuth redirect URIs : "http://google.com".
In the place of "http://google.com" you can place ur respective project Url.so,that it will redirect to your Page.
I was getting this error when trying to run my test web page directly from "file:///C:/webtests/myfile.htm". To fix it, I didn't have to make any changes to my App Settings. Instead, I just had to host my HTML file on an actual server and then hit it like: "http://localhost/myfile.htm".
Hope that helps someone.
I'm using the Facebook Canvas platform (Unity WebGL) and I don't needed to add the Website platform. The only thing I did was add my website root url in:
Product
Facebook Login
Valid OAuth redirect URIs
For me it was the "Single Sign On" (can be seen at the bottome of the screenshot in phwd's answer) setting that was turned off.
I ran into this with the IBM BlueMix SSO service and had to use the BlueMix provided redirect URL as my "site" URL instead of my actually web application site URL to fix it. Once I made that change the problem went away.
This can be caused by incorrect app-ID
In my ionic sample I had the same issue because I had inserted a different "app-ID" in my ionic app other than the app-ID I received from Facebook developer account.
so we have to carefully insert the relavent appID
Things have evolved in Facebooks approach, I now realised that you need to
"Add Product" to your App: facebook login.
make sure oauth & web auth on
add my own site url to ""Valid Auth redirect URI" (and removed the default https://www.facebook.com/connect/login_success.html which his in the
Without this I get the URL Blocked error.

Facebook One or more of the given URLs is not allowed by the App's settings

Result in console:
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.
Basically what I am trying is to enable user to login on my blog on blogspot.com, and to post on his wall some message.
here is how I configure app on facebook:
App Domains:blogspot.com
Sandbox Mode:disabled
Site URL:my_blog_name.blogspot.com/p/publishing.html
after putting site url to begin with http:// it resolve my issue.
Now my Site URL looks like this: http://my_blog_name.blogspot.com/p/publishing.html
This can also happen when the redirect_uri submitted with the https://www.facebook.com/dialog/oauth request is not present in the list of Valid OAuth redirect URIs under:
Settings >> Advanced >> Security
After much trial and error, when I added the redirect_uri that I was using (https://www.facebook.com/connect/login_success.html in my case), I suddenly got to the step past this error.
These Problem Occurs Because of You Are not correctly Configure Your Site Link in FaceBook.
Go Facebook Developers page
1.Select 'Settings'
2.Click 'ADD PlatForm'
3.Select 'Wesite'
4.Give Your Website Name
Finally Save the Settings That's All
Facebook doesn't care what actual IP address your server is located at - but it will check that the domain name of the referring page is the same as the domain you registered with facebook.The problem is that whatever url you are currently hosting your app is not setup in your Application configuration. Go to your app settings and ensure the urls are matching.
In my case it was the www. that I omitted, so for instance:
http://website.com
instead of
http://www.website.com
I had this problem because at first I didn't put app domain in the Settings page. And after I added "example.com" to the app domain field (assume URL is http://www.example.com), the problem no longer exists.
If it does'nt work even after you have setup the website URL in Settings -> Basic tab, and Settings -> Advanced -> Valid OAuth redirect URIs, Try doing the following stuff and check if it works out.
Step 1)
Goto, Settings -> Basic -> Contact Email (Fill the email id you want your app to sync with)
Step 2) Goto, Status & Review -> Status -> Enable options as yes (Make your app visible to public)
Now, restart your app and check, if it works fine..
Your application should be on the same domain of what you enter in the facebook developper's settings
Facebook App Settings
Although answered several times with similar info, this is my experience FYI
Testing on localhost - I wondered if that might be the problem, but nope.
app_id and redirect_uri included.
URLs properly encoded.
So why this error?
See Facebook Community Help as I did, for the important missing part of the puzzle.
That is:
<a href="https://www.facebook.com/dialog/share?
app_id=1234567890
&display=page
&href=http%3A%2F%2Fexample.org <-- This
&redirect_uri=http%3A%2F%2Fexample.org" <-- and This
target="_overTheRainbow">Tell the world about this awesomeness!</a>
Must match the reference URLs submitted to Facebook for the app with app_id.
Yes This is The common problem of facebook api. Don't use www before url. It will solve the problem.
I was facing same problem when I was posting links on Facebook wall.
I did this:
From https://developers.facebook.com/
On Migration tab Stream post URL security was enabled. So I just disabled it and after that it is working for me now.
Hope this solve the problem for others.
Go to settings and and then Advanced tab. At the bottom "Embedded browser OAuth Login" enable this option. then your problem is resolved.

Facebook app domain name when using localhost

From a tutorial here:
http://ankurm.com/blog/api/using-localhost-for-facebook-app-development/1091/
I tried to set up a Local development Area for my Facebook app. But when I put "http://localhost:85/my_app/" as my domain name, Facebook says
App Domains: "http://localhost:85/app-name/" should not contain protocol information.
Also when I put "localhost:85/my_app/" as my domain name, I get the error:
App Domains: localhost:85/my_app/ is not a valid domain.
It seems like the protocol has been changed.
Here is my solution (I tested on 3rd April 2015 and it works well):
In Settings -> Basic tab
App Domain: localhost
Click "+Add Platform" and choose "Website"
Site URL: http://localhost:<port>/ (<port> is your port number)
Save Changes
My solution:
Leave App Domains empty
(Products) Facebook login > Settings
Add http://localhost:85/my_app/ to Valid OAuth redirect URIs box
Save Changes
Leave App Domains empty
Go to Website with Facebook Login
Add http://localhost:port_number/
Save changes and try again.
For more information visit
http://developers.facebook.com/docs/samples/canvas/
Happy coding :-)
This has changed some over the years, but I just got it to work with a webapp that I'm running on localhost. This is what I did:
Goto https://developers.facebook.com/apps
Select your app.
Select Settings > Basic from the left hand nav bar.
Click the Add Platform button at the bottom of the page.
Click Website
Enter http://localhost:8080/ for the Site URL.
Click the Quickstart button to the far right of the Site URL you just entered.
A new tab will open. On that tab, scroll down to the section, "Tell us about your website" and again enter http://localhost:8080/ for the Site URL.
Click the Next button.
Attempted to login again, and it worked this time.
Good luck!
2018 working solution
It took me ages to figure this out, so I'm going to share my solution.
I tried all the suggested answers, but nothing worked for me, and in the end all I had to do was to go to https://developers.facebook.com/apps/YOUR_APP_ID/fb-login/settings/, and add my full callback url in the Valid OAuth redirect URIs box.
In my case, using ruby on rails, my url looked like this http://localhost:3000/user/auth/facebook/callback.
And right after I added it, everything started working! Hope this helps someone else facing this issue.
This is what I used to do.
If you are using Windows, you need to modify the host file. Host file location will be at %SystemRoot%\System32\drivers\etc\
Add a new line in host file like this
127.0.0.1 localhost.YOUR-SITE-NAME.com
Save the host file.
Go to FB apps setting control panel and give localhost.YOUR-SITE-NAME.com in Apps domain field. Save changes.
Now load you local environment like localhost.YOUR-SITE-NAME.com from your browser.
NB: change YOUR-SITE-NAME with your domain name.
Working solution (August 2018)
First, select your app in the developers dashboard.
Then make sure your app is in development mode, as it allows localhost over HTTP. To do so, click on the toggle situated at the top right of your app's page.
Finally, please follow the notes below as they could cause trouble if improperly filled:
Settings > Basic > App Domains should be empty
Products > Facebook Login > Settings > Valid OAuth Redirect URIs should be empty
You can either leave it blank or use localhost, http://localhost:85/my_app/ is the URL
When I wrote that tutorial at that time port was allowed in app domain. And I actually able to run app with 81 port (wamp server). Now it looks that facebook is not allowing port in url. You can use localhost in app domain.
I will update information as soon as possible. I am trying to find out solution.
A temporary solution is use localtunnel http://progrium.com/localtunnel/
I tested this and it works for me [Feb 2020]:
Install ngrok & get your https url (example: https://a3asdf23.ngrok.io)
Go to FB App Dashboard Settings (Basic) -> under App Domains -> add https://a3asdf23.ngrok.io, https://ngrok.io.
On the same page, scroll all the way down, Add Platform (Website), set the url as https://a3asdf23.ngrok.io. Not finish yet, click QuickStart -> under "Tell us about your website", put the same url https://a3asdf23.ngrok.io.
Then go to Products -> Facebook Login -> Settings -> Client OAuth Settings -> Valid OAuth Redirect URIs -> add these https://a3asdf23.ngrok.io, https://ngrok.io, https://a3asdf23.ngrok.io/{your-redirect-uri}.
And here you go. Thanks me later :)
You must create a tunnel to share your localhost;
Ngrok is maby the easiest way to do that.
https://ngrok.com
Go through https://ngrok.com/ link to download ngrok and extract that file.
Open cmd ( search cmd)
Go to directory where ngrok is extracted.
Open ngrok from command line ex: c:/ngrok/ngrok.exe [port] or cd c:/ngrok then ngrok 80 ( ngrok [port] )
You will get
ngrok
Tunnel Status online
Version 1.3/1.3
Forwarding http://3ahsdfhska.ngrok.com -> 127.0.0.1:80
Forwarding https://3ahsdfhska.ngrok.com -> 127.0.0.1:80
Web Interface http://127.0.0.1:4040
# Conn 0
Avg Conn Time 0.00ms
Don’t FORGET to make sure your wamp server is open on same port …
(how to check -> goto->wampicon->apache->httpd.conf search for port or 80(default) use that for ngrok.exe 80 )
http://3ahsdfhska.ngrok.com
will be URL for accessing your localhost online
I tried all the solutions mentioned here but none of them worked.
What solved my issue was copying the "OAuth redirect URI" from firebase to facebook app "Valid OAuth Redirect URIs"
I left all the domains blank
If you are getting the protocol errors, not only do you need to REMOVE the Http:// but also if there is any backslash at the end of the web address, you must remove that too or it won't work. I did this and it worked perfectly! Holla!
Tossing one more solution into the mix:
I set up my website per the instructions, then added a second app (Facebook Canvas) and set that URL to http://localhost:XXXXX. Now I can access FB both locally and in production.
I develop locally and I use this URL: localhost/fb
Then I had to add a website with the following URL: http://localhost
Under App Domains I added localhost.
Now it works. The only issue I had was, that you have to use this URL in all of your scripts. E.g.
$loginUrl = $helper->getLoginUrl('http://localhost/fb/login-callback.php', $permissions);
You can't use 127.0.0.1 here ...