any example on Goliath + OmniAuth

231 Views Asked by At

basically my last attempt was im getting this error:

[:error, "bad URI(is not URI?): ://localhost:80/auth/twitter/auth/twitter"] 

when i browse to

http://127.0.0.1/auth/twitter

this is my goliath server

class Application < Goliath::API
  use(Rack::Session::Cookie
  use OmniAuth::Strategies::Developer
  use OmniAuth::Builder do
      provider :twitter, '..', '..'
      provider :facebook, '..', '..'
      provider :developer
  end
end

interestingly /auth/developer has no issues - but twitter or facebook has.

Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

This a little bug from env variable that is missing some information for Rack::Request class construct the properly path.

The fix is very simple:

require 'omniauth'
require 'omniauth-twitter'
...
require 'goliath'

class Test < Goliath::API
  use Rack::Session::Cookie

  use Rack::Config do |env|
    env['rack.url_scheme'] ||= 'http'
    env['SCRIPT_NAME'] = nil
  end

  use OmniAuth::Strategies::Developer

  use OmniAuth::Builder do
      provider :twitter, '..', '..'
      provider :facebook, '..', '..'
      provider :developer
  end  

  def response env
    [200, {}, '']
  end
end

Just include the Rack::Config middleware with the properly parameters, like the example above.