Myself implementented SSO in my application using Authentication Exchange in c# by Dotnetopenauth
My Doubts follows,
- On Response of my AX request , i dont receive any token. should i need to send any parameter ?
- In My Application i need user to sign in on Provider everytime , but rightnow if user clicks checkbox on “sign-in automatically next time” it never asks id and password from user next time .
- AX fetchResponse null for MyopenId. does it support only Simple Registration?
Request Code:
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();
Response Code:
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;
}
}
I found that certain providers (i.e. myopenid.com) returned null for a
FetchRequestwhilst returning valid data forClaimsRequest. It appears different providers support different mechanisms for attribute exchange. In the request:and when picking up the response:
Thus we try both ways and hopefully gets the data from at least one of the methods.