如何在DotNetOpenAuth属性交换中使用FavoriteFlavor属性 [英] How to use FavoriteFlavor attribute in DotNetOpenAuth Attribute Exchange

查看:69
本文介绍了如何在DotNetOpenAuth属性交换中使用FavoriteFlavor属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码显示如何在DotNetOpenAuth中使用属性交换.

This code shows how to use Attribute Exchange with DotNetOpenAuth.

但是,如果我有自己的封闭提供者,并且想要使用自定义属性,例如在AcmeRequest中定义的FavoriteFlavor属性作为DNOA样本的一部分,该怎么办?我与DNOA有什么关系,以使请求看起来像(但对于我的FavoriteFlavor请求):

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

http://blogs.gnome.org中定义的

/jamesh/2007/11/26/openid-ax/:

推荐答案

在构建自己的OpenID提供程序时,我不确定是否需要使OpenID请求看起来完全像这样.

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

您只需要使用Fetch and Store(如果要允许保存数据)请求和响应,这非常简单.

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);

在OpendID提供程序上,您必须捕获此请求并创建FetchResponse

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.

这篇关于如何在DotNetOpenAuth属性交换中使用FavoriteFlavor属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆