How to use FavoriteFlavor attribute in DotNetOpenAuth Attribute Exchange

為{幸葍}努か 提交于 2019-12-23 03:44:09

问题


This code shows how to use Attribute Exchange with DotNetOpenAuth.

But what if I have my own closed Provider and want to use custom attributes, for example the FavoriteFlavor attribute defined in the AcmeRequest as part of the DNOA samples; what do I have to do with DNOA to make the request look like something like (but for my FavoriteFlavor request):

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

as defined in http://blogs.gnome.org/jamesh/2007/11/26/openid-ax/:


回答1:


I am not sure that you need to make the OpenID request look exactly like this when you are building your own OpenID provider.

You only need to use Fetch and Store (if you want to allowing saving of data) requests and response and it is very simple.

IAuthenticationRequest request)

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

request.AddExtension(ax);

On the OpendID provider you have to catch this request and create FetchResponse

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

var fetchResponse = new FetchResponse();
fetchResponse.Attributes.Add("http://axschema.org/contact/email", "some@email.com");
fetchResponse.Attributes.Add("http://axschema.org/namePerson", "John");

pendingRequest.AddResponseExtension(fetchResponse);

Keep in mind that these are just sort of additional steps needed for Attribute Exchange extension.



来源:https://stackoverflow.com/questions/4449883/how-to-use-favoriteflavor-attribute-in-dotnetopenauth-attribute-exchange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!