DotNetOpenID Programmatic Login
-
05-07-2019 - |
Question
I am using Dotnetopenid for my openid solution, everything is fine when using the built-in user control, but when I want to implement it programmaticaly, like the below code,
openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();
is always null. any idea?
OpenIdRelyingParty openid = createRelyingParty();
if (openid.Response != null) {
switch (openid.Response.Status) {
case AuthenticationStatus.Authenticated:
// This is where you would look for any OpenID extension responses included
// in the authentication assertion.
// var extension = openid.Response.GetExtension<SomeExtensionResponseType>();
// Use FormsAuthentication to tell ASP.NET that the user is now logged in,
// with the OpenID Claimed Identifier as their username.
State.ProfileFields = openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();
FormsAuthentication.RedirectFromLoginPage(openid.Response.ClaimedIdentifier, false);
break;
Solution
getting help from Andrew
I've missed to add extension to my request before redirecting to provider. ( this step is not coded in sample files )
to do this, after creating the request object do like this:
Dim request As IAuthenticationRequest = openid.CreateRequest(openid_identifier.Text)
' This is where you would add any OpenID extensions you wanted
' to include in the authentication request.
' request.AddExtension(someExtensionRequestInstance);
Dim myclaim As New ClaimsRequest
With myclaim
.BirthDate = DemandLevel.Request
.Country = DemandLevel.Request
.Email = DemandLevel.Request
.FullName = DemandLevel.Request
.Gender = DemandLevel.Request
.Language = DemandLevel.Request
.Nickname = DemandLevel.Request
.PostalCode = DemandLevel.Request
.TimeZone = DemandLevel.Request
End With
request.AddExtension(myclaim)
' Send your visitor to their Provider for authentication.
request.RedirectToProvider()
code is in vb.net
OTHER TIPS
Noted to be fixed and made clearer in next release.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow