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

Open
andrei4002 opened this Issue Jun 26, 2012 · 9 comments

Comments

Projects
None yet
9 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

This comment has been minimized.

Show comment
Hide comment
@jphenow

jphenow Jul 6, 2012

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

jphenow commented Jul 6, 2012

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

@xlozinguez

This comment has been minimized.

Show comment
Hide comment
@xlozinguez

xlozinguez Aug 12, 2012

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 ;)

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

This comment has been minimized.

Show comment
Hide comment
@BartlomiejSkwira

BartlomiejSkwira Aug 30, 2013

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.

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

This comment has been minimized.

Show comment
Hide comment
@adammcnamara

adammcnamara Nov 14, 2014

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

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

@philipgiuliani

This comment has been minimized.

Show comment
Hide comment
@philipgiuliani

philipgiuliani Aug 3, 2015

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

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

@Dragsbaek

This comment has been minimized.

Show comment
Hide comment
@Dragsbaek

Dragsbaek Dec 31, 2015

+1

+1

@tzafrir

This comment has been minimized.

Show comment
Hide comment
@tzafrir

tzafrir Jan 11, 2016

Still causing headaches in 2016

tzafrir commented Jan 11, 2016

Still causing headaches in 2016

@tzafrir

This comment has been minimized.

Show comment
Hide comment
@tzafrir

tzafrir Jan 11, 2016

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

tzafrir commented Jan 11, 2016

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

@tmilewski

This comment has been minimized.

Show comment
Hide comment
@tmilewski

tmilewski Feb 12, 2017

Member

@tzafrir is correct. What are the use-cases of redirecting a callback/user to a .json file?

Member

tmilewski commented Feb 12, 2017

@tzafrir is correct. What are the use-cases of redirecting a callback/user to a .json file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment