我没有通过这部分认证:
If signed out of App, but signed into the App Center, the App should launch when launching from the App Center without asking for credentials
我的应用程序基于使用 DotNetOpenAuth 的 intuits "HelloIntuitAnywhere" c# 演示。
protected void Page_Load(object sender, EventArgs e)
{
#region OpenId
// Hide Connect to Quickbooks widget and show Sign in widget
IntuitInfo.Visible = false;
IntuitSignin.Visible = true;
// If Session has keys
if (HttpContext.Current.Session.Keys.Count > 0)
{
// If there is a key OpenIdResponse
if (HttpContext.Current.Session["OpenIdResponse"] != null)
{
// Show the Sign in widget and disable the Connect to Quickbooks widget
IntuitSignin.Visible = false;
IntuitInfo.Visible = true;
}
// Sow information of the user if the keys are in the session
if (Session["FriendlyIdentifier"] != null)
{
friendlyIdentifier.Text = Session["friendlyIdentifier"].ToString();
}
if (Session["FriendlyName"] != null)
{
friendlyName.Text = Session["FriendlyName"].ToString();
}
else
{
friendlyName.Text = "User Didnt Login Via OpenID, look them up in your system";
}
if (Session["FriendlyEmail"] != null)
{
friendlyEmail.Text = Session["FriendlyEmail"].ToString();
}
else
{
friendlyEmail.Text = "User Didnt Login Via OpenID, look them up in your system";
}
}
#endregion
#region oAuth
// If session has accesstoken and InvalidAccessToken is null
if (HttpContext.Current.Session["accessToken"] != null && HttpContext.Current.Session["InvalidAccessToken"] == null)
{
// Show oAuthinfo(contains Get Customers Quickbooks List) and disable Connect to quickbooks widget
oAuthinfo.Visible = true;
connectToIntuitDiv.Visible = false;
}
#endregion
}
如何识别用户已登录应用中心并绕过我的登录屏幕/部分?
我有这段代码(来自 OpenIdHandler.aspx.cs)可以工作,除了我不想在用户未登录时重定向到 intuit 登录页面。我想显示登录按钮。
public partial class OpenIdHandler : System.Web.UI.Page
{
/// <summary>
/// Action Results for Index, uses DotNetOpenAuth for creating OpenId Request with Intuit
/// and handling response recieved.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="e">Event Args.</param>
protected void Page_Load(object sender, EventArgs e)
{
//OpenId Relying Party
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var openIdIdentifier = ConfigurationManager.AppSettings["openid_identifier"];
var response = openid.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(openIdIdentifier, out id))
{
try
{
IAuthenticationRequest request = openid.CreateRequest(openIdIdentifier);
FetchRequest fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email));
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName));
request.AddExtension(fetch);
request.RedirectToProvider();
}
catch (ProtocolException ex)
{
throw ex;
}
}
}
else
{
if (response.FriendlyIdentifierForDisplay == null)
{
Response.Redirect("/OpenIdHandler.aspx");
}
// Stage 3: OpenID Provider sending assertion response
Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
FetchResponse fetch = response.GetExtension<FetchResponse>();
if (fetch != null)
{
Session["OpenIdResponse"] = "True";
Session["FriendlyEmail"] = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
Session["FriendlyName"] = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);
}
//Check if user disconnected from the App Center
if (Request.QueryString["disconnect"] != null && Request.QueryString["disconnect"].ToString(CultureInfo.InvariantCulture) == "true")
{
Session["Flag"] = true;
Response.Redirect("CleanupOnDisconnect.aspx");
}
else
{
Response.Redirect("Default.aspx");
}
}
}
}