2009-04-25 2 views
10

나는 authlogic-example-app으로 게임을하고 있는데, 사용자 등록시 OpenID 제공 업체 (내 경우 Google과 Yahoo)의 이메일 주소를 가져 오지 못하고 있습니다. resp. 전자 메일 주소 대신 빈 응답을받습니다 (아래 코드의 주석을 확인하십시오).Ruby-OpenID : OpenID 제공 업체의 이메일 주소 필요

이것은 내 사용자 모델이 보이는 방식입니다 (위에서 언급 한 authlogic-example-app의 "with_openid"- 브랜치와 비슷한 모든 것). 누락 된 '이메일'외에도 openid 인증 프로세스는 예상대로 작동합니다.

class User < ActiveRecord::Base 
    acts_as_authentic do |c| 
    # not needed because I use OpenID 
    c.validate_login_field = false 
    # avoid failed validation before OpenID request 
    c.validate_email_field = false 
    # this one sets 'openid.sreg.required=email' 
    c.required_fields = [:email] 
    end 

    private 

    # overwriting the existing method in '/lib/authlogic_openid/acts_as_authentic.rb' 
    def map_openid_registration(registration) 
    # this is my problem: 'registration' is an empty hash 
    self.email ||= registration[:email] if respond_to?(:email) && !registration[:email].blank? 
    end 

end 

어떤 문제 해결 방법이 있습니까? authlogic을 사용하기 전에이 작업을 수행 한 사람이 있습니까? 또는 더 나은 점 : 실제 사례가 있습니까?

업데이트은 : 인증하고 가져


예 요청 : 나는 Google 계정 인증 API 문서에 example requests와 (ruby-openid-gemopenid-authentication-plugin 사용) Google Account Authentication API을 확인하고 authlogic에 의해 제출 된 요청을 비교 Google의 이메일 주소 :

https://www.google.com/accounts/o8/ud 
?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0 
&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select 
&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select 
&openid.return_to=http%3A%2F%2Fwww.example.com%2Fcheckauth 
&openid.realm=http%3A%2F%2Fwww.example.com%2F 
&openid.assoc_handle=ABSmpf6DNMw 
&openid.mode=checkid_setup 
&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0 
&openid.ext1.mode=fetch_request 
&openid.ext1.type.email=http%3A%2F%2Faxschema.org%2Fcontact%2Femail 
&openid.ext1.required=email 
내 appliation에 의해 제출 된

요청 :

https://www.google.com/accounts/o8/ud 
?openid.assoc_handle=AOQobUcdICerEyK6SXJfukaz8ygXiBqF_gKXv68OBtPXmeafBSdZ6576 
&openid.ax.mode=fetch_request 
&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select 
&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select 
&openid.mode=checkid_setup 
&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0 
&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0 
&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1 
&openid.realm=http%3A%2F%2Flocalhost%3A3000%2F 
&openid.return_to=http%3A%2F%2Flocalhost%3A3000%2Faccount%3Ffor_model%3D1%26_method%3Dpost%26open_id_complete%3D1 
&openid.sreg.required=email 

전체 설치를 디버깅하는 동안, 나는 openid-authentication-plugin은 적어도이, 그것은 오픈 ID 공급자로부터받은 응답 이메일을 수신하지 않는다는 것을 발견했습니다 내 사용자 모델의 registration 해시가 비어있는 이유는 ... 설명

UPDATE : 당신이 authlogic 및 오픈 ID로 주위를 연주하는 경우, latest railscast on this subject을 확인하는 것을 잊지 마세요!

답변

10

아무도 나를 도울 수 없기 때문에, 나는 자신을 도왔습니다. :-)

내 질문에 짧은 대답은 :이 줄을 사용하여

c.required_fields = [:email,"http://axschema.org/contact/email"] 

는 응용 프로그램이 sreg과 도끼 (구글에서 지원 요청 형)를 사용하여 전자 메일 주소를 요청합니다.

당신은 더 자세한 대답하고 바로 여기 Javascript OpenID-Selector와 authlogic - 오픈 ID의 작업 구현을 찾을 수 있습니다 :이 올바른 방향으로 나를 지적하는 동안

http://github.com/vazqujav/authlogic_openid_selector_example/

+0

이 필드가 활성화되면 오류가 발생합니다 ... : 0x2643d84> ... without these : # c.required_fields = [ "http://axschema.org/contact/email"] # sreg로 이메일 가져 오기 # c.optional_fields = [ "email"] 작동합니다. – holden

+0

@holden : 내가 제출 한 github-issue에 대한 답변으로이 문제를 설명했습니다. – Javier

+0

당신은 또한이 포크에 흥미가있을 것입니다. (README에 따라) 일부 SReg 대 AX 선택을 다루는 것입니다 : https://github.com/binaryfeed/open_id_authentication - 질문, 본질적으로 주제와 관련이있는 것처럼 보입니다. – lindes

0

OpenID 시퀀스의 모든 부분을 디버깅 할 수 있으므로 제어하는 ​​OpenID 서버에 대한 테스트. Google의 OpenID 제공 업체가 올바른 일을한다는 보장은 없습니다.필드를 사용하여 적어도 올바른 작업을 수행해야한다고 확신하기 때문에 Verisign의 서버를 확인해보십시오.

코드 스 니펫이 나에게 적합합니다.

3

을, 내가 필요한 것은이었다

c.openid_required_fields = [:email,"http://axschema.org/contact/email"] 

이것은 이메일을 가져 와서 설정했습니다.

나는이 나라 이름을 가져올 수 여전히 수 없어요하지만 http://code.google.com/apis/accounts/docs/OpenID.html#Parameters @ 규정이 여러 값을 가져

2
# fetch email by ax 
c.openid_required_fields = [ 
          "http://axschema.org/contact/email", 
          "http://axschema.org/namePerson/first", 
          "http://axschema.org/namePerson/last", 
          "http://axschema.org/contact/country/home", 
          "http://axschema.org/pref/language" 
          ] 

은 ... 이름, 이메일은, 언어가 완벽하게 작동합니다!

0

것은 내가 공급자에서 매개 변수를 가져올 수 있어요하지만, 객체로 을 내가 오픈 ID : AX :: FetchResponse.from_success_response (open_id_response)를 사용하고 있습니다 ... 응답에서 그들을 추출 할 수 없습니다 오전 어떤 방법으로 이메일, 닉네임, 국가 등을 추출 할 수 있습니까?