2010-12-15 25 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

相關問題