我没有通过这部分认证:
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的直觉“HelloIntuitAnywhere”c#demo。
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
}
如何识别用户已登录App Center并绕过我的登录屏幕/部分?
我有这段代码(来自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");
}
}
}
}
答案 0 :(得分:2)
当用户从App Center重定向到您的应用程序时,请使用OpenID获取用户的电子邮件地址并将其签名到您的应用程序中。由于用户已经授权连接,您还可以获取realmId。
答案 1 :(得分:1)
我的解决方法有两个方面:
我的应用程序基于intuit演示......在Global.asax.cs中,我删除了导致我所有问题的重定向,因为无论我将被重定向到default.aspx(反过来又是重定向我登录)。
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
//Response.Redirect("Default.aspx"); //<-----
}
感谢。