问题
I'm using open_id_authentication gem to authenticate to google. In my sessions controller I call
authenticate_with_open_id(complete_identity_url, OPENID_OPTS) do |openid_result, identity_url, registration|
and it returns 401 status code Unauthenticated. But it should show google page in which I must confirm access.
I made example app: https://github.com/mbashirov/rails3-test, it only has code in sessions controller and routes set.
That code works perfectly on rails 2.3 app. There is error?
Thanks.
Solution.
In sessions controller add
class SessionsController < ApplicationController
include OpenIdAuthentication
In config/application.rb add
config.app_middleware.use OpenIdAuthentication
After this two steps all works fine.
回答1:
If it works in 2.3 and then doesn't work in 3, it sounds like an error not of your own making.
Next steps:
1) Upgrade to latest 3.1 (or better 3.1.1) Rails
2) Contact the authors of the gem to see what their 3.1 support plans are. They may already be working on a solution that you can help test.
3) If you have the skills, it would be awesome for you to contribute back by solving the problem.
I suggest that you start with an Ether peek tool such as Fiddler or a Mac tool to see if your machine is sending out the same requests/getting the same responses when running 3.1.1 vs 2.3.
Then debug....
来源:https://stackoverflow.com/questions/7446143/rails-3-0-9-open-id-authentication