내 응용 프로그램에 레일 플러그인 open_id_authentication을 사용하고 있습니다. 이 작업은 MyOpenID에서 가능하지만 Google 인증을 사용하면 필수 속성의 일부로 이메일 주소를 가져올 수 없습니다.Google/Yahoo in Rails에서 OpenID AX 특성 검색
내가 아는 바로는 Google은 sreg 속성 요청을 무시하고 전자 메일 주소에 대해서만 AX 스키마를 수신합니다.
def open_id_authentication(openid_url)
#google only responds to AX for email, so we must provide that also
authenticate_with_open_id(openid_url, :required => [:nickname, :email, 'http://axschema.org/contact/email']) do |result, identity_url, registration|
if result.successful?
@user = User.find_or_initialize_by_identity_url(identity_url)
if @user.new_record?
unless registration['email'] || registration['http://axschema.org/contact/email']
failed_login "Your OpenID provider didn't send us an email address."
return
end
#some providers (like Google) won't send a nick name. We'll use email instead for those
nick = registration['nickname']
nick |= registration['email']
nick |= registration['http://axschema.org/contact/email']
email = registration['email'];
email |= registration['http://axschema.org/contact/email']
@user.login = nick
@user.email = email
@user.save(false)
end
self.current_user = @user
successful_login
else
failed_login result.message
end
end
나의 이해는 내가 필요으로 이메일 주소 (sreg 및 AX 모두)를 제출하고 내가 전달되는 registration
예에서 그들을 끌어 할 수 있어야한다는 것입니다 : 여기
Google에 로그인하면 이메일 주소가 't'로 다시 전달됩니다.
이 문제를 올바르게 처리하고 있습니까? Google에서 사용자의 이메일 주소를 얻으려면 어떻게해야합니까? 야후를 지원하기 위해 다른 농구를 뛰어 넘어야합니까?
아, 내 블로그 게시물이 마음에 듭니다. http://blog.nerdbank.net/2009/03/how-to-pretty-much-guarantee-that-you.html 덧붙여 말하자면, Google은 axschema.org 형식도 꽤 확신합니다. –
이메일에 대해 3 개의 다른 URL이 있지만 google은 http://schema.openid.net/contact/email (내 테스트에서)에만 응답합니다. 이것은 매우 성가시다. 속성 교환과 관련하여 좀 더 유연 해지지 않아야 할 것처럼 보입니다. –
Google이 axschema.org URL에 응답하지 않는 이유를 모르겠습니다. 여기에 하나 있고 실행 : http://testingauth.heroku.com, 출처 : http://github.com/shripadk/authlogic_openid_selector_example, 어느 정도는 stackoverflow 자동 등록과 유사합니다. axschema 형식을 사용하고 Google은 이메일 ID로 응답합니다. –