[英]auto login to website when redirected from intuit
I am failing this part of the certification: 我没有通过认证的这一部分:
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
I am basing my application on intuits "HelloIntuitAnywhere" c# demo which uses DotNetOpenAuth. 我将应用程序基于使用DotNetOpenAuth的直观“ 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
}
How do I identify that the user is already signed in to the App Center and by-pass my login screen/section? 如何确定用户已经登录到App Center并绕过我的登录屏幕/部分?
I have this piece of code (from OpenIdHandler.aspx.cs) that works EXCEPT I want to to not redirect to the intuit login page when the user is not logged in. I want to display the login button. 我有这段代码(来自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");
}
}
}
}
When the user is redirected to your application from the App Center, use OpenID to fetch the user's email address and sign them into your app. 从App Center将用户重定向到您的应用程序后,请使用OpenID提取用户的电子邮件地址并将其登录到您的应用程序中。 Since the user has already authorized the connection, you will also be able to fetch the realmId.
由于用户已经授权了连接,因此您还可以获取realmId。
https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0020_connect/0011_from_the_intuit_app_center/implement_openid_in_your_app https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0020_connect/0011_from_the_intuit_app_center/implement_openid_in_your_app
My fix is two fold: 我的解决方法有两个:
I was basing my application on the intuit demo... In Global.asax.cs I removed the redirect which was causing all my problems since no matter what I would be redirected to default.aspx (which in turn redirects me to login). 我将应用程序基于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"); //<----- }
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.