Sign in through GitHub

RailsCasts Pro episodes are now free!

Learn more or hide this

pseudonymous-foss's Profile

GitHub User: pseudonymous-foss

Comments by


Whenever I use the JS/Coffee code to log in using a pop-up I got:

(facebook) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError

Turns out this is due to a bug in omniauth-facebook 1.4.1 -- downgrading to 1.4.0 made it work.

Also, instead of hardcoding the path in the coffee file, I used:

window.location = '<%= Rails.application.routes.url_helpers.send(:user_omniauth_callback_path, :facebook) %>' if response.authResponse

Perhaps a little unwieldy - and I'd like to know a shorter way of doing this, but it works.

The above is akin to calling


In views etc.

PS ! Found out about the error from:


Getting 401 when clicking your twitter authentication link ?

You're probably developing on localhost!

What to do ? Edit the callback url in your twitter app.

Problem? Doesn't like localhost urls with ports in it (possibly disliking everything localhost in general).

What to do, then ? Encode your localhost url in a url shortener!

Example: http://localhost:3000/auth/twitter/callback

I used Google's URL shortener (@ ) - simply set the address given by your URL-shortener of choice as the value of "Website: " under "Application Details".

Done and done.

PS!: Ryan didn't explicitly say this, but to use the ENV['TWITTER_SECRET'] etc you can set these values under environments/{development.rb,production.rb} like so:

ENV['TWITTER_SECRET'] = 'ssssh it is a SECRET!'