0
自己在使用C#中驗證交換我的應用程序implementented SSO通過Dotnetopenauth谷歌openID問題標記?
我的疑慮如下,
- 在我的AX請求的響應,我不接受任何令牌。我需要發送任何參數嗎?
- 在我的應用程序中,我需要用戶每次都登錄提供程序,但是如果用戶在「下次自動登錄」時單擊複選框,它就再也不會從用戶那裏詢問用戶名和密碼。
- AX fetchResponse null用於MyopenId。它是否僅支持簡單註冊?
請求代碼:
IAuthenticationRequest request = openid.CreateRequest(txt_openid_identifier.Text);
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.Clear();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last); fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.HomeAddress.Country);
request.AddExtension(fetchRequest);
// Issue request to OP
request.RedirectToProvider();
響應代碼:
using (var openid = new OpenIdRelyingParty())
{
var response = openid.GetResponse();
if (response == null) return;
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
string emailID = string.Empty;
Session["email"] = string.Empty;
Session["name"] = string.Empty;
Session["country"] = string.Empty;
Session["Accesskey"] = string.Empty;
Session["SecretAccesskey"] = string.Empty;
var fetchResponse = response.GetExtension<FetchResponse>();
if (fetchResponse.Attributes.Contains(WellKnownAttributes.Contact.Email))
{
IList<string> emailAddresses =
fetchResponse.Attributes[WellKnownAttributes.Contact.Email].Values;
emailID = emailAddresses.Count > 0 ? emailAddresses[0] : null;
}
else
emailID = string.Empty;
}
}