Ruby, Sinatra , omniauth-github Authentication Failure Callback Error
===

ok it has been over 5 hours and i am still getting no where. What i am trying to do is setup omniauth-gihub gem in one of my Ruby-Sinatra based applications. Following is What i have done yet.

Added the Gems to the Gemfile (& Ran bundler update command ofcourse):


    source 'https://rubygems.org'

    gem 'sinatra'
    gem 'haml'
    gem 'shotgun'
    gem 'omniauth', :git => 'git://github.com/intridea/omniauth.git'
    gem 'omniauth-github', :git => 'git://github.com/intridea/omniauth-github.git'


Under my app.rb file i have the following code:


    #imports
    require 'rubygems'
    require 'bundler'
    require 'sinatra'
    require 'omniauth'
    require 'omniauth-github'
    require 'haml'
    require './helpers.rb'

    #Configure OmniAuth
    use OmniAuth::Builder do
      provider :github, ENV['api_key'], ENV['secret'], # Removing the key and secret for security reasons
      scope: "user,repo,gist"
    end

    #Application Settings
    set :sessions, true
    set :views, 'templates'


    #Get Method for Application Root
    get '/' do
      haml :index
    end

    #Get/Post Methods For Authentication
    %w(get post).each do |method|
      send(method, "/auth/:provider/callback") do
        env['omniauth.auth']
      end 
    end

The Github application's settings are as follows:

    URL = 127.0.0.1:4567
    Callback URL = 127.0.0.1:4567

Now whenever i visit 127.0.0.1:4567/auth/github/callback i get the following error:

    I, [2012-07-26T07:05:23.540462 #30458]  INFO -- omniauth: (github) Callback phase initiated.
    E, [2012-07-26T07:05:23.540700 #30458] ERROR -- omniauth: (github) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError
    localhost - - [26/Jul/2012:07:05:23 IST] "GET /auth/github/callback HTTP/1.1" 302 9
    - -> /auth/github/callback
    localhost - - [26/Jul/2012:07:05:23 IST] "GET /auth/failure?message=invalid_credentials&strategy=github HTTP/1.1" 404 448
    - -> /auth/failure?message=invalid_credentials&strategy=github
    localhost - - [26/Jul/2012:07:05:23 IST] "GET /favicon.ico HTTP/1.1" 404 447
    - -> /favicon.ico

it seems it's not even trying to connect to github, i thought i was already logged in so i logged out of github and try visiting 127.0.0.4567/auth/github/callback again and yes it is not even connecting or sending any information to github.

I have check my api key and the secret and they are correct. I can't really figure out what am i missing and am really tired. Any help or suggestion will be much appreciated.

Thanks in advance !