public void TestSetup() { this._consumerProfile = new ConsumerProfile() { ConsumerKey = "ConsumerKey", ConsumerSecret = "ConsumerSecret" }; this._restProfile = new RestProfile() { AppToken = "AppToken", DataSource = 1, OAuthAccessToken = "OAuthAccessToken", OAuthAccessTokenSecret = "OAuthAccessTokenSecret", RealmId = "RealmId" }; this._quickBooksAuthenticatedUserCredentials = new QuickBooksOnlineAuthenticatedUserCredentials( this._restProfile.RealmId, this._restProfile.OAuthAccessToken, this._restProfile.OAuthAccessTokenSecret, this._restProfile.DataSource); this._quickBooksNonAuthenticatedUserCredentials = new QuickBooksOnlineNonAuthenticatedUserCredentials( this._restProfile.AppToken, this._consumerProfile.ConsumerKey, this._consumerProfile.ConsumerSecret, "http://localhost:27286/home/Callback"); this._quickBooksService = new QuickBooksOnlineService(this._quickBooksAuthenticatedUserCredentials, this._quickBooksNonAuthenticatedUserCredentials); }
public QuickBooksOnlineServiceSdk(RestProfile restProfile, ConsumerProfile consumerProfile) { this.RestProfile = restProfile; this.ConsumerProfile = consumerProfile; this._requestValidator = new OAuthRequestValidator(this.RestProfile.OAuthAccessToken, this.RestProfile.OAuthAccessTokenSecret, this.ConsumerProfile.ConsumerKey, this.ConsumerProfile.ConsumerSecret); this._serviceContext = new ServiceContext(this.RestProfile.AppToken, this.RestProfile.RealmId, IntuitServicesType.QBO, this._requestValidator); this._dataService = new DataService(this._serviceContext); this._queryServiceItem = new QueryService <Item>(this._serviceContext); this._queryServicePayment = new QueryService <Payment>(this._serviceContext); this._queryServiceAccount = new QueryService <Account>(this._serviceContext); this._queryServicePurchaseOrder = new QueryService <PurchaseOrder>(this._serviceContext); this._queryServiceBill = new QueryService <Bill>(this._serviceContext); this._queryServiceSalesReceipt = new QueryService <SalesReceipt>(this._serviceContext); this._queryServiceInvoice = new QueryService <Invoice>(this._serviceContext); this._queryServiceCustomer = new QueryService <Customer>(this._serviceContext); }
public QuickBooksOnlineService(QuickBooksOnlineAuthenticatedUserCredentials quickBooksAuthenticatedUserCredentials, QuickBooksOnlineNonAuthenticatedUserCredentials quickBooksNonAuthenticatedUserCredentials) { this._restProfile = new RestProfile() { AppToken = quickBooksNonAuthenticatedUserCredentials.AppToken, DataSource = quickBooksAuthenticatedUserCredentials.DataSource, OAuthAccessToken = quickBooksAuthenticatedUserCredentials.OAuthAccessToken, OAuthAccessTokenSecret = quickBooksAuthenticatedUserCredentials.OAuthAccessTokenSecret, RealmId = quickBooksAuthenticatedUserCredentials.RealmId, }; this._consumerProfile = new ConsumerProfile() { ConsumerKey = quickBooksNonAuthenticatedUserCredentials.ConsumerKey, ConsumerSecret = quickBooksNonAuthenticatedUserCredentials.ConsumerSecret, }; this._quickBooksOnlineServiceSdk = new QuickBooksOnlineServiceSdk(this._restProfile, this._consumerProfile); }
protected override async Task ApplyProfile(ProfileBase profile) { if (_subscriber != null) { await _subscriber.DisposeAsync(); _subscriber = null; } if (profile is RestProfile restProfile) { _profile = restProfile; var requestClient = CreateRequestClient(); var tokenProvider = new TokenProvider(CreateRequestClient, _profile.ServerUser, _profile.ServerPassword); var token = await tokenProvider.GetToken(); var serverUri = new Uri(_profile.ServerName); var signalRUri = new Uri(serverUri, "/cosei"); var subscriber = new SignalRSubscriber(signalRUri.AbsoluteUri, options => { options.Headers.Add("Authorization", $"Bearer {token}"); }, exception => { _dispatcher.BeginInvokeOnMainThread(async() => await _errorService.ShowAlert(exception)); }); var snippetStore = new SnippetStore(requestClient, tokenProvider); var csScriptRunService = new CsScriptRunService(_clipboardService); SnippetService = new SnippetService(snippetStore, _messenger, csScriptRunService, _dispatcher, subscriber, _profile.ServerUser); var userStore = new UserStore(requestClient, tokenProvider); UserService = new UserService(userStore, _messenger, _dispatcher, subscriber); await subscriber.StartAsync(); _subscriber = subscriber; } }
public void TestSetup() { this._consumerProfile = this._testDataReader.ConsumerProfile; this._restProfile = this._testDataReader.RestProfile; //this._quickBooksOnlineServiceSdk = new QuickBooksOnlineServiceSdk( this._restProfile, this._consumerProfile ); this._quickBooksAuthenticatedUserCredentials = new QuickBooksOnlineAuthenticatedUserCredentials( this._restProfile.RealmId, this._restProfile.OAuthAccessToken, this._restProfile.OAuthAccessTokenSecret, this._restProfile.DataSource); this._quickBooksNonAuthenticatedUserCredentials = new QuickBooksOnlineNonAuthenticatedUserCredentials( this._restProfile.AppToken, this._consumerProfile.ConsumerKey, this._consumerProfile.ConsumerSecret, "http://localhost:27286/home/Callback"); this._quickBooksService = new QuickBooksOnlineService(this._quickBooksAuthenticatedUserCredentials, this._quickBooksNonAuthenticatedUserCredentials); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString.HasKeys()) { var oauthVerifyer = Request.QueryString["oauth_verifier"].ToString(); RestProfile profile = RestProfile.GetRestProfile(); profile.RealmId = Request.QueryString["realmId"].ToString(); switch (Request.QueryString["dataSource"].ToString().ToLower()) { case "qbo": profile.DataSource = (int)IntuitServicesType.QBO; break; case "qbd": profile.DataSource = (int)IntuitServicesType.QBD; break; } OAuthConsumerContext consumerContext = new OAuthConsumerContext { ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(), ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"].ToString(), SignatureMethod = SignatureMethod.HmacSha1 }; IOAuthSession clientSession = new OAuthSession(consumerContext, Constants.OauthEndPoints.IdFedOAuthBaseUrl + Constants.OauthEndPoints.UrlRequestToken, Constants.OauthEndPoints.IdFedOAuthBaseUrl, Constants.OauthEndPoints.IdFedOAuthBaseUrl + Constants.OauthEndPoints.UrlAccessToken); try { IToken accessToken = clientSession.ExchangeRequestTokenForAccessToken((IToken)Session["requestToken"], oauthVerifyer); profile.OAuthAccessToken = accessToken.Token; profile.OAuthAccessTokenSecret = accessToken.TokenSecret; profile.Save(); } catch { } } }
public void TestSetup() { this._consumerProfile = this._testDataReader.ConsumerProfile; this._restProfile = this._testDataReader.RestProfile; this._quickBooksOnlineServiceSdk = new QuickBooksOnlineServiceSdk(this._restProfile, this._consumerProfile); }
protected void Page_Load(object sender, EventArgs e) { var openIdRelyingParty = new OpenIdRelyingParty(); var openid_identifier = ConfigurationManager.AppSettings["openid_identifier"]; var returnUrl = "~/OpenID/Connect.aspx"; 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.aspx"); } // 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(RestProfile.GetRestProfile()); Response.Redirect("~/ManageConnection.aspx"); } else if (userName != null) { FormsAuthentication.SetAuthCookie(userName, true); if (!string.IsNullOrEmpty(returnUrl)) { Response.Redirect("~/Default.aspx"); } } } } }