1

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/:

Community
  • 1
  • 1
Confused
  • 869
  • 1
  • 7
  • 16
  • I see your question is answered. But to help clarify for others, the `AcmeRequest` class is a sample custom OpenID extension, whereas what you're looking for here is a custom attribute in AX. It's much easier to use a custom attribute in AX than it is to write your own OpenID extension. – Andrew Arnott Dec 18 '10 at 01:32

1 Answers1

2

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.

Robert Vuković
  • 4,677
  • 6
  • 31
  • 47
  • Thanks Robert, that is really helpful and got me closer to what I want to achieve. I have further [questions on the Acme example](http://groups.google.com/group/dotnetopenid/browse_thread/thread/a9ed4db2a36a75ad) that hopefully Andrew willl pick up. Thanks again. – Confused Dec 16 '10 at 10:38
  • [This post at weblogs](http://weblogs.asp.net/jdanforth/archive/2008/07/11/fetching-user-details-from-openid-via-attribute-exchange.aspx) is also helpful. – Confused Dec 16 '10 at 16:01