Skip to content

Loading…

When calling /auth/:identity/callback.json , request.env["omniauth.auth"] is nil #618

Open
andrei4002 opened this Issue · 8 comments

8 participants

@andrei4002

Let's say that I have to connect with facebook.

My app works perfectly if i call

/auth/facebook/callback

or

/auth/facebook/callback?format=json

but when i try to call

/auth/facebook/callback.json

there is no request.env[ "omniauth.auth" ]

(it's nil)

Any ideas of what's going on? (I'll provide more additional info if asked. not sure what else is needed)

@jphenow

:+1: Though I'm having the issue with a a custom provider - working on ownership of both the provider and the client

@xlozinguez

Thanks @andrei4002 , you solved an issue of mine... can't figure out why callback.js wouldn't work... anyway callback?format=js does the trick for us ;)

@BartlomiejSkwira

Same problem here on a rails-api app which renders just json. In my case a Google Api redirect_uri can't be with parameters, when I try to add ?format=json in console and midddleware initializer I get

(google) Authentication failure! invalid_credentials: OAuth2::Error, redirect_uri_mismatch:                                                                                              
{                                                                                                           
  "error" : "redirect_uri_mismatch"                                                                                                                                               
}

Seems that I will have to respond to html and set session manually.

@adammcnamara

+1 to this issue. Does anyone know the root cause why .json doesn't work?

@philipgiuliani

Still open after 3 years? Have the same issue, and it really should get fixed..

@tzafrir

Still causing headaches in 2016

@tzafrir

I browsed a little and it seems that in https://github.com/intridea/omniauth/blob/master/lib/omniauth/strategy.rb,

callback_path is hardcoded to be /auth/facebook/callback, and when current_path is compared to expected strategy's path (current_path.casecmp(path) == 0) the test fails and omniauth doesn't kick in.

Quick fix: use ?format=json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.