My iframe application don't render facebook tags, I tried to change to connect url to localhost/port but it still not working, is anyone have any suggestion?
For clarification I can see some text in my application, I just can't see the facebook tags
(It's happend to my in Facebook Developer Toolkit iframe sample code)
Thanks
----------------------edit---------------------------
I don't sure where to find the callback url, and the connect url because I didn't found them under the facebook application setting configurations- I think the set of the url connect is , this was the original setting, and I found in some forum that I need to change it to localhost/port
Could you elaborate on your settings, particularly for the connect url? You can't put "localhost" into the Facebook settings - their servers don't know who you are when you say that. To them "localhost" means that facebook server. You need to enter your external IP address, and you may also need to open port 80 to let them load your page from there too.
If your application is otherwise working, then you must have put the correct IP in the callback url, otherwise nothing would be working. Whatever the case, the callback url and connect url must be on the same domain.
Related
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 ...
after searching the web for a while, I am still not able to find the correct solution to my problem; How to make sure the browser is redirected to the https app url. Since the canvas app is an iframe, we don't have access to change the window.top.location to the https equivalent.
If the visitor comes to
http://apps.facebook.com/app_name/
I want him redirected to
https://apps.facebook.com/app_name/
Totally unable to fix it with javascript in the app loaded in the canvas since top.location is impossible to tamper with due to cross-domain origin rules. It could have been fixed easily with a redirect rule implemented by Facebook, and I am surprised it's not a checkbox in the Facebook app setup to enforce SSL. We do not want our game to be accessible over http.
I have tested to set both Canvas URL and Secure Canvas URL to point to the https url, but that gives this error (cross-domain trouble): Unsafe JavaScript attempt to access frame with URL http://apps.facebook.com/app_name/ from frame with URL https://s-static.ak.facebook.com/
Please advice.
Ok, so it is possible to redirect the top window. I must have had a typo when I tested it the first time. This tiny script does the trick:
<script>
if ( window.location.protocol == 'http:' ) {
window.top.location = 'https://apps.facebook.com/app_name/';
}
</script>
However, I still don't understand why this isn't an option in the app setup on Facebook. It would have been a lot more efficient and user friendly with a server side redirect rule.
Problem
I have an application driving a tab on a client's page. The application works correctly if the user has not enabled FB's "secure browsing" feature. If attempting to view over HTTPS, the iframe doesn't even appear (no errors, no mixed-content warnings). When correctly loading over HTTP, the div with the id "pagelet_app_runner" has an iframe inserted into it and the application content is loaded inside there. Over HTTPS, this div remains empty and the iframe is not inserted into the page. There are no Javascript errors appearing in Firebug or Chrome's equivalent console.
Why I'm Asking Here
The host has a valid SSL certificate and there is no 'mixed content' at the URL in question. I can successfully view the content over HTTP or HTTPS by visiting the URL directly, and I can do the same by visiting apps.facebook.com/canvasURL/tabURL. It is only when attempting to view within a Page Tab that the HTTPS load fails as described above. My application is configured with both regular and secure canvas and tab URLs.
Attempted Debugging
I've recorded some sessions with Charles but since the iframe isn't being inserted into the page, I think I'm coming at the problem after it's already occured. I'm no Charles expert so happy to be corrected here.
Apache isn't seeing any request (in either regular or ssl logs) for the affected loads. non-SSL loads come through as expected in access_log.
Plea for Help
I'm out of ideas for debugging this. Does anybody have any suggestions? What really obvious and stupid mistake might I have made? :)
edit: nicer formatting
Your app canvas URL is https://skinnycomp.nextstudio.com.au/skinnycowcomps/ , which send 404 error to Facebook proxy (request is going through proxy when viewing app via tab), also when viewing your app via apps (https://apps.facebook.com/122381834451561/), again 404... maybe Facebook proxy is ignoring 404 and posting blank...
Try changing canvas URL to https://skinnycomp.nextstudio.com.au/skinnycowcomps/tab, also you can check if your app is accessed via page tab, in signed_request there should be page_id...
23:51:15.379[549ms][total 1667ms] Status: 404[Not Found]
GET https://skinnycomp.nextstudio.com.au/skinnycowcomps/
This is a real longshot since I'm sure you've triple checked all the settings, but the blank page can happen if an invalid url is specified in the Page Tab URL field in the app settings. Since it only happens on https, it would imply something specifically with the Secure Page Tab URL entry. It might be worth checking that again, and maybe even re-saving it or changing it to something else to see if it helps.
I was using relative URLs for the regular and secure tab URL fields. From memory relative URLs here were mandatory at some point in the past. It appears now that a relative URL will still work for HTTP but not for HTTPs. Fix: absolute URLs. Hopefully FB update their field validation to match what's required too.
I've added facebook login to my site. However, when I click the button, I get a red box that says:
Invalid Argument
Given URL is not allowed by the Application configuration.
If I continue to login then I get:
API Error Code: 100
API Error Description: Invalid parameter
Error Message: next is not owned by the application.
Not sure exactly what the problem is. Any thoughts are appreciated.
Your settings must be incorrect.
Go to http://www.facebook.com/developers/ and edit the application you're working on.
On the "website" tab, look for "Site URL". This should be set to your website's URL "http://yoursite.com/"
Note that if you're using subdomains, you'll also need to update "Site Domain" to be "yoursite.com"
You can set up a developer application and set the url to localhost.com:port
Make sure to map localhost.com to localhost on your hosts file
Works for me
Also check to see if you are missing the www in the url which was on my case
i was testing on http://www.mywebsite.com and in the facebook app i had set
http://mywebsite.com
I was getting this problem while using a tunnel because I:
had the tunnel url:port set in
the FB app settings
but was
accessing the local server by
pointing my browser to
"http://localhost:3000"
once i started punching the tunnel url:port into the browser, i was good to go.
i'm using Rails and Facebooker, but might help others just the same.
According to http://developers.facebook.com/docs/reference/dialogs/oauth/
for me worked
https://apps.facebook.com/YOUR_APP_NAMESPACE (watch fot http:// or https:// issue)
I kept getting this error, when using wildcard subdomains with my app.
I had the site url set to: http://myapp.com and app domain also to http://myapp.com, and also the same value for the Valid OAuth redirect URIs in the advanced tab of the settings app.
I tried different combinations but only setting the http://subdomain.myapp.com as the redirect value worked, of course only for that subdomain.
The solution was to empty the redirect fields, leave it blank, that worked! ;)
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