问题
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