how to test develop facebook app with google app engine on local machine - facebook

Is it possible to develop facebook using google app engine locally, without having to upload application every time I change it?

I assume you are getting API error 191 when you try to access the Facebook API from the dev appserver?
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
If you are developing on your localhost, you can set the 'Site Domain' field in your facebook app settings to (appname).appspot.com and then edit the HOSTS file on your system.
In my environment I just entered:
127.0.0.1 devlocal.(appname).appspot.com
As long as the browser's URL matches *.(appname).appspot.com, it will work.

You could set the Website field in your Facebook app settings to http://localhost:XXXX or http://127.0.0.1:XXXX for development and then change it over to the actual once ready for deployment. This worked well for me.

I ran into this issue a couple years ago and wrote a long article about how I solved it for my needs.
http://www.upwithabang.com/articles/GAE-facebook-win7.html
It covers the setting up of an Apache server on your laptop then telling Facebook and the GAE to behave as if it hosted on a production server. This solves the pain of constant uploads for testing every little change.
Hopefully this is helpful to someone, if not a little late.

Related

Cant test FB SDK login locally even though I have set my domain and site URL (app is test mode)

I am developing a web app with Facebook integration and I can't figure out why I can't test the login function locally. I have looked through the answers here (How to Test Facebook Connect Locally) and have tried to follow the steps of having the app in test mode, setting the site URL and the domain.
Based on FBs documentation here: https://developers.facebook.com/blog/post/2018/06/08/enforce-https-facebook-login/
I should be able to use http for localhost development, but I get the error
The method FB.api can no longer be called from http pages. https://developers.facebook.com/blog/post/2018/06/08/enforce-https-facebook-login/
and can't log in. Below are pictures of my app settings (including an indication it is an app in 'test mode').
So this is really only a half answer, but it seemed easier for me to just force https for my local development using mkcert (https://github.com/FiloSottile/mkcert). After creating local certs I updated my site URL to say https://localhost:8080 and I am able to log in without issue.

Google Sign in error 403 - Project marked for deletion

I've recently integrated play-silhouette 4.0.0 with Play 2.5 to handle authentication. I am allowing my users to login with Google and as such am using Silhouette's OAuth2 features. I am redirected to Google's authorization page properly but after pressing allow the app fails with
403 - Project marked for deletion
I have enabled the Google+ API in the developer's console and am requesting the scopes "profile email" from the service. I've also deployed the sample app and get the same error. The error codes listed by Google are not much help - anyone have an idea? I've been testing on my local machine.
I resolved this issue:
Create a new project in the Google Developer Console.
Enable Google+ API.
Create OAuth Credentials.
Perhaps I created the credentials before I enabled the API. Seems a bit silly order would matter. Hope this is helpful to someone else!

Facebook login - how to develop on both localhost and in production?

I am developing a website which uses the Facebook login. Now, I want to be able to get this to work both in my production environment, as well as in my development environment.
On Facebook, I can give ONE site url, which Facebook can redirect to. This worked great during my development phase, but now I want it both to work in production, but also while developing my solution.
I guess one way would be to run my application on the local IIS with my domain-navn and change my hosts file, but that can't seriously be the most easy solution!?
- What is the easiest way to get it to work in both environments?
Update: As of 2018 the path to this setting is now Products > Facebook Login > Settings > Client OAuth Settings the rest of this answer is still valid.
There is a better way. You just need to add valid callback URL's for your localhost to Settings > Advanced > OAuth Settings.
This method allows you still have your production website URL while allowing oauth from dev, staging, production, etc.
After I have worked with this for ~6 months, I have found a solution which works really well, based on the other two answers.
In Facebook I add two apps:
Production app
Dev app
Then, in my web.config app settings I have:
<!--Prod-->
<add key="_FacebookApiId" value="id"/>
<add key="_FacebookApiSecretId" value="secret_id"/>
<!--Dev-->
<add key="FacebookApiId" value="dev_id"/>
<add key="FacebookApiSecretId" value="dev_secret_id"/>
Which of course is read through a helper-class.
Then it works seamlessly on both production and localhost, and both myself and my team is happy.
I have the same problem.
The only solutions I have found are:
yes... edit the host file on your local machine: How to Test Facebook Connect Locally
create another Facebook app only for development purposes: Facebook Oauth on localhost for testing during development (the blog is about Rails but the solution to use different apps depending on the environment is still valid for other languages)
Facebook only allows localhost OAuth redirects when your app is in development mode. This means you can't run your application in production and perform local development tests.
Instead, you need to create a test variant of your app. Head to https://developers.facebook.com and view the dashboard for your production application. Click the drop-down menu at the top-left and choose Create Test App.
This populates a test application with almost the same settings as your production app. However, it gives you a new app ID and app secret, so you'll need to toggle these settings when running in development mode (as other answers suggest).
Here's some further info on test apps: https://developers.facebook.com/docs/apps/test-apps/
Following the advice in this answer, it will work if set the Mobile URL to be your development domain (ie. localhost) and the Site URL to be your production domain.
The updated way.
In the App Dashboard, choose your app and go to Products > Facebook
Login > Settings. Under the Client OAuth Settings, enter your redirect
URL in the Valid OAuth redirect URIs field for successful
authorization.
Go to https://developers.facebook.com/docs/facebook-login/web for more info.

Develop and Test a Facebook application

Typically I develop my websites on trunk, then merge changes to a testing branch where they are put on a 'beta' website, and then finally they are merged onto a live branch and put onto the live website.
With a Facebook application things are a bit tricky. As you can't view a Facebook application through a normal web browser (it has to go through the Facebook servers) you can't easily give each developer their own version of the website to work with and test.
I have not come across anything about the best way to develop and test a Facebook application while continuing to have a stable live website that users can use. My question is this, what is the best practice for organising the development and testing of a Facebook application?
I hope I understood your question correctly.
What we have is 2 versions of our app, that is two applications defined in facebook.
We have the regular version that runs on deploy, and we have the myapp-test version.
this version runs on the domain myapptest.com (or you can use myapp.local).
In your HOSTS file (%winder%\system32\drivers\etc) define this url and redirect it to your own server on localhost (127.0.0.1).
Now, all you need is a config file on each machine that is not updated via source-control.
The localhost (development) version uses the app_id for the myapp-test, and relevant settings.
The deploy uses the other settings.
Then when you deploy you just need to upload your code.

New session on every page view when running Facebook application in IFrame in IE and Azure

I am developing a Facebook application and I am using Facebook C# SDK v4.2.1 to help with authentication. I am building the application using ASP.NET MVC 2 and am hosting it in Windows Azure (SDK v1.2).
Everything has been running fine when I had my application in a full browser window, but now when I am attempting to IFrame it in Facebook, I run into session problems. The behavior is that a new session is created on every new page request so the user always comes back to the application's login page. I can see that that Facebook session is valid when Facebook redirects back to the application after authorization, but when I set some session variables and redirect to another page, the session is gone.
When I debug the application locally, both as a standalone web application and in the Development Fabric, everything works fine. It is only when it's published to Azure that I get the problems. I have tried to have a local debug environment that is very similar to production where I have the facebook application at apps.facebook.com/myappnamedev that points to localhost on a specific port.
I just now also discovered that I only see the problem in IE (I am using v.8). Firefox v3.6 and Safari v.5 works fine.
Any ideas to help my troubleshooting? I have spent 10 hours on it and it's getting really frustrating... I am happy to paste code/configuration info if needed, just let me know.
Thank you in advance!
// Peter
I solved this. The redirect from Facebook after authentication landed on different pages in my development environment compared when deployed to Azure. I moved my authentication logic to global.asax instead.