public void saveAuthorizationToSettings(Dictionary<string, string> valuesFromCallback, IToken authorizedAccessToken)
 {
     IppRealmOAuthProfile ippRealmOAuthProfile = new IppRealmOAuthProfile();
     ippRealmOAuthProfile.realmId = Request.QueryString["realmId"].ToString();
     switch (Request.QueryString["dataSource"].ToString().ToLower())
     {
         case "qbo": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBO; break;
         case "qbd": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBD; break;
     }
     ippRealmOAuthProfile.accessToken = authorizedAccessToken.Token;
     ippRealmOAuthProfile.accessSecret  = authorizedAccessToken.TokenSecret;
     ippRealmOAuthProfile.expirationDateTime = DateTime.Now;
     ippRealmOAuthProfile.Save();
 }
Exemple #2
0
        public void saveAuthorizationToSettings(Dictionary <string, string> valuesFromCallback, IToken authorizedAccessToken)
        {
            IppRealmOAuthProfile ippRealmOAuthProfile = new IppRealmOAuthProfile();

            ippRealmOAuthProfile.realmId = Request.QueryString["realmId"].ToString();
            switch (Request.QueryString["dataSource"].ToString().ToLower())
            {
            case "qbo": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBO; break;

            case "qbd": ippRealmOAuthProfile.dataSource = (int)IntuitServicesType.QBD; break;
            }
            ippRealmOAuthProfile.accessToken        = authorizedAccessToken.Token;
            ippRealmOAuthProfile.accessSecret       = authorizedAccessToken.TokenSecret;
            ippRealmOAuthProfile.expirationDateTime = DateTime.Now;
            ippRealmOAuthProfile.Save();
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var openIdRelyingParty = new OpenIdRelyingParty();
            var openid_identifier  = ConfigurationManager.AppSettings["openid_identifier"];
            var returnUrl          = "~/OpenID/Connect";
            var response           = openIdRelyingParty.GetResponse();

            if (response == null)
            {
                // Stage 2: user submitting Identifier
                Identifier id;
                if (Identifier.TryParse(openid_identifier, out id))
                {
                    IAuthenticationRequest request = openIdRelyingParty.CreateRequest(openid_identifier);
                    FetchRequest           fetch   = new FetchRequest();
                    fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email));
                    fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName));
                    fetch.Attributes.Add(new AttributeRequest("http://axschema.org/intuit/realmId"));
                    request.AddExtension(fetch);
                    request.RedirectToProvider();
                }
            }
            else
            {
                if (response.FriendlyIdentifierForDisplay == null)
                {
                    Response.Redirect("~/OpenID/Connect");
                }

                // Stage 3: OpenID Provider sending assertion response
                //Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
                FetchResponse fetch = response.GetExtension <FetchResponse>();
                if (fetch != null)
                {
                    var openIdEmail    = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
                    var openIdFullName = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);
                    var openIdRealmId  = fetch.GetAttributeValue("http://axschema.org/intuit/realmId");

                    string userName = Membership.GetUserNameByEmail(openIdEmail);
                    if (userName == null)
                    {
                        Membership.CreateUser(openIdEmail, Guid.NewGuid().ToString(), openIdEmail);
                        FormsAuthentication.SetAuthCookie(openIdEmail, true);
                        if (Request.QueryString["Subscribe"] != null)
                        {
                            String csname           = "DirectConnectScript";
                            Type   cstype           = this.GetType();
                            ClientScriptManager csm = Page.ClientScript;

                            // Check to see if the startup script is already registered.
                            if (!csm.IsStartupScriptRegistered(cstype, csname))
                            {
                                StringBuilder cstext = new StringBuilder();
                                cstext.AppendLine("<script>");
                                cstext.AppendLine("$(document).ready(function () {");
                                cstext.AppendLine("intuit.ipp.anywhere.directConnectToIntuit();");
                                cstext.AppendLine("});");
                                cstext.AppendLine("</script>");
                                csm.RegisterStartupScript(cstype, csname, cstext.ToString());
                            }
                        }
                    }
                    else if (Request.QueryString["Disconnect"] != null)
                    {
                        RestHelper.clearProfile(IppRealmOAuthProfile.Read());
                        Response.Redirect("~/ManageConnection");
                    }
                    else if (userName != null)
                    {
                        FormsAuthentication.SetAuthCookie(userName, true);
                        if (!string.IsNullOrEmpty(returnUrl))
                        {
                            Response.Redirect("~/Default");
                        }
                    }
                }
            }
        }