Is there any way I can trigger omniauth callback manually?
What I mean to say is, I get the oauth response from twitter in json, can I then POST/GET this data to the omniauth callback url ? If so, is there any specific format in which I should re-structure the json data?
I am doing something on these lines but unable to populate the request.env['omniauth.auth'] in the omniauth callback.
Here is the request spec
before(:each) do
# response returned from twitter is in spec/fixtures/oauth_twitter_response.json
twitter_oauth_response = File.join(Rails.root.to_s, 'spec', 'fixtures', 'oauth_twitter_response.json')
data = File.read(twitter_oauth_response)
@twitter_data = JSON.parse(data)
end
it 'should post the twitter data to omniauth callback' do
post 'users/auth/twitter/callback', {}, {:env => {"omniauth.auth" => @twitter_data}}
end
any idea if this is possible at all?
This is possible. The only thing you’re missing is what you’re having trouble with – setting
omniauth.auth. You do it like this: