开发者

Example of supplying SREG/AX in DotNetOpenAuth

开发者 https://www.devze.com 2022-12-28 19:32 出处:网络
I can\'t find any example of supplying SREG/AX extension on Provider (OP) side in DotNetOpenAuth. 开发者_StackOverflow

I can't find any example of supplying SREG/AX extension on Provider (OP) side in DotNetOpenAuth.

开发者_StackOverflow

All constructors of ClaimsResponse are internal. Any help/suggestions?


Thanks to Matthew Johnson, who helped with the answer:

You need a ClaimsRequest first. Then you can generate a ClaimsResponse with ClaimsRequest.CreateResponse();


Using ASP.Net MVC, I have:

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消