2010-12-15 26 views
1

This code显示了如何使用DotNetOpenAuth进行属性交换。如何使用DotNetOpenAuth中的FavoriteFlavor属性属性交换

但是如果我有我自己的封闭提供程序并希望使用自定义属性,例如AcmeRequest中定义的FavoriteFlavor属性作为DNOA示例的一部分;我有什么用DNOA做,使请求看起来类似(但我FavoriteFlavor要求):

openid.ns.ax=http://openid.net/srv/ax/1.0 
openid.ax.mode=fetch_request 
openid.ax.required=name,hackergotchi 
openid.ax.if_available=email,web 
openid.ax.type.name=http://axschema.org/namePerson 
openid.ax.type.email=http://axschema.org/contact/email 
openid.ax.type.hackergotchi=http://axschema.org/media/image/default 
openid.ax.type.web=http://axschema.org/contact/web/default 

http://blogs.gnome.org/jamesh/2007/11/26/openid-ax/定义:

+0

我看到你的问题得到解答。但为了帮助澄清其他人,“AcmeRequest”类是一个自定义的OpenID扩展示例,而您在此寻找的是AX中的一个自定义属性。在AX中使用自定义属性要比编写自己的OpenID扩展容易得多。 – 2010-12-18 01:32:52

回答

2

我不知道,你需要做的当您构建自己的OpenID提供程序时,OpenID请求看起来完全如此。

你只需要使用Fetch and Store(如果你想允许保存数据)请求和响应,这很简单。

IAuthenticationRequest request) 

var ax = new FetchRequest(); 
ax.Attributes.AddRequired("http://axschema.org/contact/email"); 
ax.Attributes.AddRequired("http://axschema.org/namePerson"); 

request.AddExtension(ax); 

在你要抓住这个请求,并创建FetchResponse

var fetchRequest = pendingRequest.GetExtension<FetchRequest>(); 

var fetchResponse = new FetchResponse(); 
fetchResponse.Attributes.Add("http://axschema.org/contact/email", "[email protected]"); 
fetchResponse.Attributes.Add("http://axschema.org/namePerson", "John"); 

pendingRequest.AddResponseExtension(fetchResponse); 

请记住,这些只是那种需要属性交换扩展额外的步骤OpendID提供商。

+0

感谢Robert,这真的很有帮助,让我更接近我想要达到的目标。我还有更多[关于Acme示例的问题](http://groups.google.com/group/dotnetopenid/browse_thread/thread/a9ed4db2a36a75ad),希望Andrew willl能够拿起。再次感谢。 – Confused 2010-12-16 10:38:58

+0

[此博文在博客](http://weblogs.asp.net/jdanforth/archive/2008/07/11/fetching-user-details-from-openid-via-attribute-exchange.aspx)也是有帮助的。 – Confused 2010-12-16 16:01:57

相关问题