How to Test Your Facebook App Locally Using HTTPS

Facebook now requires you to use https for your Valid OAuth Redirect URIs for apps.  This is true even when your app is in development mode.

In order to get an https address, you could use a gem like tunnels or tunnelss, but I found using ngrok easier.

To get it to work:

  1. I went to their website and downloaded their program
  2. I extracted the file for the program
  3. In my console, I went into the directory where ngrok was extracted to and entered ‘grok http 3000’ on my Windows machine, other machines may use ‘./grok http 3000’
  4. After entering that, ngrok will provide you an https address which you put into the Valid OAuth Redirect URIs field in Facebook
  5. Once you fire up your server, you should be able to access it using that https address instead of localhost:3000

Simple Authentication with Rails 3.1

If you need a simple authentication, for example some views that only one person should have access to, you might consider:

http_basic_authenticate_with :name => "username", :password => "pass"

provided by Rails 3.1, it’s a way to protect some pages that only a select few may need access to. Just place that in your controller.
To limit the actions this applies to, you can add :only or :except such as:

http_basic_authenticate_with :name => "username", :password => "pass", :except => :index