views:

130

answers:

1

My dears friend i´m try to get the email from google user that sign in with the OpenId but i can´t.

I Have that code


    public ActionResult Google(FormCollection fc)
    {
        var openid = new OpenIdRelyingParty();

        IAuthenticationResponse response = openid.GetResponse();

        switch (response.Status)
        {
            case AuthenticationStatus.Authenticated:
                var claim = response.GetExtension<ClaimsResponse>();
                string email = null, fullname = null;
                if (claim != null)
                {
                    email = claim.Email;
                    fullname = claim.FullName;
                    Session["Email"] = email;
                }
                string identifier = response.ClaimedIdentifier;
                break;
        }

        return View("LogOn");
    }
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Google(string openid_identifier)
    {
        var openid = new OpenIdRelyingParty();
        IAuthenticationRequest request = openid.CreateRequest(openid_identifier);
        var fields = new ClaimsRequest();
        fields.Email = DemandLevel.Request;
        fields.FullName = DemandLevel.Request;
        request.AddExtension(fields);
        return request.RedirectingResponse.AsActionResult();
    }

Please Help me, i don´t know anything else to do. Thanks.