I previously posted regarding the ASP.NET controls I wrote to wrap JanRain’s .NET implementation of OpenID. I have updated those controls to now automatically request user profile information from your visitors’ OpenID providers as needed. This post discusses how you can do that.
The JanRain library provides the AuthRequest.ExtraArgs NameValueCollection to add the profile variables you wish to get from the OpenID provider. By filling in that collection, and then reading the response from HttpContext.Request.QueryString, you can readily retrieve the desired user data (including name, gender, zip, email, etc.) It does take reading the spec (which is simple) on what those variable names and values are.
Or you can use my updated ASP.NET OpenID controls. Just download and use them as outlined in my previous post, and then set any combination of these properties on the controls to get the profile information you want:
- RequestNickname
- RequestFullName
- RequestEmail
- RequestBirthdate
- RequestGender
- RequestPostalCode
- RequestLanguage
- RequestCountry
- RequestTimeZone
Setting any of these properties to true should cause their provider to ask the user’s consent to release the information you ask for (as the spec dictates) and provided they agree, the details will be given along with the authentication encryption.
You can optionally set the PolicyUrl property on the controls to let the user know where your privacy policy can be found before he releases the information.