Marko Anastasov wrote this on October 14, 2010

OmniAuth delivers OAuth2-based authentication done right

With OmniAuth there are no more excuses for not integrating Facebook, Twitter or any popular OAuth2 provider in your login system. That’s because it is Rack middleware, you just need to load it in your app and voilà - going to /auth/twitter or /auth/facebook will initiate the authentication request, delivering a hash full of user data to the action covering the /auth/something/callback.

When testing Facebook login in development environment, you might see an error like

{
  "error": {
    "type": "OAuthException",
    "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration."
  }
}

Facebook requires your callback URL to be on the same domain as the site URL of the Facebook application that is registered to access the information. The solution is to create a dummy app that has site URL http://localhost:3000/ (note the trailing slash).

comments powered by Disqus

About Marko Anastasov

Rendered Text co-founder. Started with code, currently more focused on people and words. Foosball striker and entry-level cyclist.

Suggested Reads

Rails Testing Handbook

A new ebook on building test-driven Rails apps with RSpec and Cucumber.

At Rendered Text, we have a long history with Ruby on Rails. Checking the blog archive reminds me that we published first posts about working with Rails way back in 2009.

———

Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.