Pregunta

Estoy usando Dotnetopenid para mi solución openid, todo está bien cuando se usa el control de usuario incorporado, pero cuando quiero implementarlo de manera programática, como el código de abajo,

openid.Response.GetExtension<DotNetOpenId.Extensions.SimpleRegistration.ClaimsResponse>();

siempre es nulo. alguna 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;
¿Fue útil?

Solución

obtener ayuda de Andrew

He omitido agregar una extensión a mi solicitud antes de redirigir al proveedor. (este paso no está codificado en archivos de muestra)

para hacer esto, después de crear el objeto de solicitud, haga lo siguiente:

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

el código está en vb.net

Otros consejos

Notado para ser arreglado y aclarado en la próxima versión.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top