开发者

Infamous Nil Object Error w/ OmniAuth

You can see this error on SO:

Nil object error when using OmniAuth (which normally works)

OmniAuth / Rail开发者_开发问答s - You have a nil object when you didn't expect it

I have the same issue with my OmniAuth strategy. I've written my own, and have tested it both locally on Rails and Sinatra. Both instances return the same error, with Sinatra displaying more helpful information.

"You have a nil object when you didn't expect it!

You might have expected an instance of ActiveRecord::Base.

The error occurred while evaluating nil.[]="

It looks like there's some Rack stuff going on behind the scenes that I'm not understanding. Sinatra's last comment in the trace is:

"../lib/rack/utils.rb in set_cookie_header!" at line 194:

case header["Set-Cookie"]

I'm not messing with cookies, though. It seems like this problem goes away randomly for certain people, or doing something simple as clearing the cache has worked for someone. None of those techniques have worked for me. Does anyone know a tried and true way for solving this issue? You can view the repo for the project here: https://github.com/stevenhaddox/oa-casport Thanks!

EDIT: After a lot of thought, I'm guessing OmniAuth doesn't like the fact that my Rack middleware is not configured for SSL. Is there a way to tell OmniAuth to not expect SSL?


It looks like you're forgetting to redirect(callback_path) at the end of the request_phase. Once you add that in I think you'll fall right back in line with the OmniAuth workflow towards getting your auth_hash returned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜