簡體   English   中英

從intuit重定向時自動登錄網站

[英]auto login to website when redirected from intuit

我沒有通過認證的這一部分:

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#演示。

    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");
            }
        }
    }
}

從App Center將用戶重定向到您的應用程序后,請使用OpenID提取用戶的電子郵件地址並將其登錄到您的應用程序中。 由於用戶已經授權了連接,因此您還可以獲取realmId。

https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0020_connect/0011_from_the_intuit_app_center/implement_openid_in_your_app

我的解決方法有兩個:

  1. 在Intuit應用程序管理器中,設置應用程序URL:mywebsite.com/OpenIdHandler.aspx
  2. 我將應用程序基於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"); //<----- } 

謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM