13-12-2010 22:55:49
Lúc bấm vào cái button Login = openauthentication viết thế này
protected void OpenId_Click(object src, CommandEventArgs e)
{
string discoveryUri = e.CommandArgument.ToString();
OpenIdRelyingParty openid = new OpenIdRelyingParty();
UriBuilder b = new UriBuilder(Request.Url);
b.Query = "";
IAuthenticationRequest req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);
FetchRequest ax = new FetchRequest();
ax.Attributes.Add(new AttributeRequest("http://axschema.org/namePerson/friendly", true));
ax.Attributes.Add(new AttributeRequest("http://axschema.org/contact/email", true));
ax.Attributes.Add(new AttributeRequest("http://axschema.org/namePerson", true));
req.AddExtension(ax);
req.RedirectToProvider();
}
còn khi page load thì viết thế này
OpenIdRelyingParty rp = new OpenIdRelyingParty();
IAuthenticationResponse r = rp.GetResponse();
FetchResponse ax = r.GetExtension(typeof(FetchResponse)) as FetchResponse;
AttributeValues areq = ax.Attributes["http://axschema.org/contact/email"];
string email = areq.Values[0].ToString();
là lấy được email thôi. Đơn giản ấy mà