2011-08-30 5 views
1

내 애플리케이션을 사용하면 Google 또는 Yahoo의 OpenID를 사용하여 로그인 할 수 있습니다. 사용자가 YouTube에 업로드 할 수있는 기능도 있습니다. 일부 사용자는 무언가를 만들고 YouTube에 업로드하는 목적으로 YouTube 컨텍스트를 통해 도착합니다. 이 사용자는 OpenID를 통해 Google 계정의 주소와 OAuth를 통해 자신의 YouTube 계정에 모두 액세스 할 수 있도록 애플리케이션을 인증해야합니다. 사용자에 대한 단일 승인 클릭으로이 작업을 수행하고 싶습니다.openid4java를 사용하는 YouTube 용 OpenID + OAuth

나는 여기에서 이것을 보았다 : http://www.youtube.com/create/Xtranormal. 이 응용 프로그램에서 Google 오픈 ID 엔드 포인트에 송신 요청은 다음과 같습니다

https://accounts.google.com/o/openid2/auth? 
openid.ns=http://specs.openid.net/auth/2.0& 
openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select& 
openid.identity=http://specs.openid.net/auth/2.0/identifier_select& 
openid.return_to=http://www.xtranormal.com/social/openid/complete/?next%3Dhttp%253A%252F%252Fyoutube.xtranormal.com%252Fytmm%252Fauth_popup_done%252F%26janrain_nonce%3D2011-08-29T16%253A35%253A53ZW0VqRw& 
openid.assoc_handle=AOQobUcMlV0Hmk431QROK27UegIYqYffiPeCuZ8gsB2x5ULYP0FXuoDZ& 
openid.ax.mode=fetch_request& 
openid.ax.required=ext0,ext1,ext2& 
openid.ax.type.ext0=http://axschema.org/namePerson/first& 
openid.ax.type.ext1=http://axschema.org/namePerson/last& 
openid.ax.type.ext2=http://axschema.org/contact/email& 
openid.mode=checkid_setup& 
openid.ns.ax=http://openid.net/srv/ax/1.0& 
openid.ns.oauth=http://specs.openid.net/extensions/oauth/1.0& 
openid.ns.sreg=http://openid.net/extensions/sreg/1.1& 
openid.oauth.consumer=www.xtranormal.com& 
openid.oauth.scope=http://gdata.youtube.com/& 
openid.realm=http://www.xtranormal.com/& 
openid.sreg.optional=postcode,country,nickname,email,fullname 

(잘 작동) 응용 프로그램에 다른 모든 오픈 ID 지원은, OpenID4Java로 기록됩니다. This answer에있는 도움말을 구현하여 비슷한 요청을 만들려고했지만 YouTube의 저에게 묻는 Google 팝업을받지 못해서 이메일 주소 만 묻습니다.

나는이 메시지 확장을 추가하여 대답에서 매개 변수를 추가 해요 : 내 요청이처럼 보이게

public class OAuthHybridRequest implements MessageExtension{ 
    public static String SCOPE_YOUTUBE = "http://gdata.youtube.com/"; 
    ParameterList parameters; 
    public OAuthHybridRequest(String scope){ 
     parameters = new ParameterList(); 
     parameters.set(new Parameter("consumer", DeploymentProperties.getDeploymentProperty("OAUTH_CONSUMER_KEY"))); 
     parameters.set(new Parameter("scope", scope)); 
    } 
    public ParameterList getParameters() { 
     return parameters; 
    } 
    public String getTypeUri() { 
     return "http://specs.openid.net/extensions/oauth/1.0"; 
    } 
    ... 
} 

을 :

https://accounts.google.com/o/openid2/auth? 
openid.ns=http://specs.openid.net/auth/2.0& 
openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select& 
openid.identity=http://specs.openid.net/auth/2.0/identifier_select& 
openid.return_to=http://martin.test.example.no/socialdelegation/hybrid/youtube/sso/auth?is_callback%3Dtrue%26requestedURL%3D%252Fmovieeditor%252Fscripts%252Fpopupcloser.jsp& 
openid.realm=http://martin.test.example.no& 
openid.assoc_handle=AOQobUcMkuyp1pVZjpF-b8dVqTfB6Y6IyOZxihsk-XD1DOq0xv06lrlPgaJEF-ITUCdJiXPi& 
openid.mode=checkid_setup& 
openid.ns.ext1=http://specs.openid.net/extensions/oauth/1.0& 
openid.ext1.consumer=test.example.no& 
openid.ext1.scope=http://gdata.youtube.com& 
openid.ns.sreg=http://openid.net/sreg/1.0& 
openid.sreg.required=fullname,nickname,email& 
openid.ns.ext3=http://openid.net/srv/ax/1.0& 
openid.ext3.mode=fetch_request& 
openid.ext3.type.email=http://axschema.org/contact/email& 
openid.ext3.type.firstName=http://axschema.org/namePerson/first& 
openid.ext3.type.lastName=http://axschema.org/namePerson/last& 
openid.ext3.type.userName=http://axschema.org/namePerson/friendly& 
openid.ext3.type.gender=http://axschema.org/person/gender& 
openid.ext3.type.fullName=http://axschema.org/namePerson& 
openid.ext3.required=email,firstName,lastName,userName,gender,fullName 

내가 무슨 말이냐?

답변

2

openid4java zip 파일 from here (comment 8) 용 oauth ext를 다운로드하고 프로젝트에 클래스를 추가하십시오. 그런 다음 :

+0

감사합니다. 좋은 소식입니다. 더 빨리 보았 더라면 좋겠습니다. 그러나 구현 후 Google 팝업은 여전히 ​​YouTube에 대해 이메일을 보내지 않습니다. 영역을 http : //*.example.com으로 변경하려고 시도했지만 아무 소용이 없습니다. 그게 왜 일어날 수 있는지 아십니까? – juell

+0

@OhHiThere'https : // gdata.youtube.com'을 범위 (https 대신 http)로 사용해 보셨습니까? (그런데 여러 범위를 사용할 때 범위 사이에 공간을 사용해야합니다.) –

+0

아니면 openid 요청에 oauth ext가 실제로 추가되지 않았습니다. Firefox "Tamper Data"부가 기능을 사용하여 리디렉션을 확인하고 oauth 매개 변수가 추가되었는지 확인하십시오. –