在DotNetOpenAuth中提供SREG / AX的示例

时间:2010-05-03 18:06:20

标签: openid dotnetopenauth openid-provider

我在DotNetOpenAuth中找不到在Provider(OP)端提供SREG / AX扩展的任何示例。

ClaimsResponse的所有构造函数都是内部的。 任何帮助/建议?

2 个答案:

答案 0 :(得分:0)

感谢Matthew Johnson,他帮助了the answer

  

您首先需要一个ClaimsRequest。然后   你可以生成一个ClaimsResponse   ClaimsRequest.CreateResponse();

答案 1 :(得分:0)

使用ASP.Net MVC,我有:

private static OpenIdRelyingParty openid = new OpenIdRelyingParty();

var req = openid.CreateRequest(Request.Form["openid_identifier"]);
var fields = new ClaimsRequest();                       
fields.Email = DemandLevel.Request;
fields.FullName = DemandLevel.Request;
fields.Nickname = DemandLevel.Request;
req.AddExtension(fields);

// make the request and your response will now contain the fields

var claim = response.GetExtension<ClaimsResponse>();
string email = null, fullname = null, nickname = null;
if (claim != null)
{
    email = claim.Email;
    fullname = claim.FullName;
    nickname = claim.Nickname;
}