def qb_callback(request): """ Part of OAuth's flow. Handles the callback from QBO, with access token and realm ID. Stores access_token, access_token_secret and realmId as variables stored in session and redirects to index view. :param request: :return HttpResponseRedirect: """ client = QuickBooks(sandbox=True, consumer_key=QUICKBOOKS_CLIENT_KEY, consumer_secret=QUICKBOOKS_CLIENT_SECRET) client.authorize_url = request.session['authorize_url'] client.request_token = request.session['request_token'] client.request_token_secret = request.session['request_token_secret'] client.set_up_service() client.get_access_tokens(request.GET['oauth_verifier']) realm_id = request.GET['realmId'] access_token = client.access_token access_token_secret = client.access_token_secret # Store variables in the session variables needed for API calls request.session['realm_id'] = realm_id request.session['access_token'] = access_token request.session['access_token_secret'] = access_token_secret return redirect('/')
def setUp(self): QuickBooks(sandbox=True, consumer_key=os.environ.get('CONSUMER_KEY'), consumer_secret=os.environ.get('CONSUMER_SECRET'), access_token=os.environ.get('ACCESS_TOKEN'), access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'), company_id=os.environ.get('COMPANY_ID'))
def setUp(self): self.qb_client = QuickBooks( sandbox=True, consumer_key=os.environ.get('CONSUMER_KEY'), consumer_secret=os.environ.get('CONSUMER_SECRET'), access_token=os.environ.get('ACCESS_TOKEN'), access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'), company_id=os.environ.get('COMPANY_ID')) self.name = "Test Class {0}".format(datetime.now().strftime('%d%H%M'))
def setUp(self): self.session_manager = Oauth1SessionManager( sandbox=True, consumer_key=os.environ.get('CONSUMER_KEY'), consumer_secret=os.environ.get('CONSUMER_SECRET'), access_token=os.environ.get('ACCESS_TOKEN'), access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'), ) self.qb_client = QuickBooks(session_manager=self.session_manager, sandbox=True, company_id=os.environ.get('COMPANY_ID'))
def qb_connect(request): """ Part of OAuth's flow. Sends a request to authenticate to QBO's authorize url. :param request: :return HttpResponseRedirect: """ client = QuickBooks(sandbox=True, consumer_key=QUICKBOOKS_CLIENT_KEY, consumer_secret=QUICKBOOKS_CLIENT_SECRET, callback_url=CALLBACK_URL) authorize_url = client.get_authorize_url() request_token = client.request_token request_token_secret = client.request_token_secret # Store request token, request token secret and authorize url in the # session for use in the callback request.session['authorize_url'] = authorize_url request.session['request_token'] = request_token request.session['request_token_secret'] = request_token_secret return redirect(authorize_url)
def setUp(self): self.session_manager = Oauth2SessionManager( sandbox=True, client_id=os.environ.get('CLIENT_ID'), client_secret=os.environ.get('CLIENT_SECRET'), access_token=os.environ.get('AUTH2_ACCESS_TOKEN'), ) self.qb_client = QuickBooks(session_manager=self.session_manager, sandbox=True, company_id=os.environ.get('COMPANY_ID2')) self.account_number = datetime.now().strftime('%d%H%M') self.name = "Test Account {0}".format(self.account_number)
def setUp(self): self.session_manager = Oauth1SessionManager( sandbox=True, consumer_key=os.environ.get('CONSUMER_KEY'), consumer_secret=os.environ.get('CONSUMER_SECRET'), access_token=os.environ.get('ACCESS_TOKEN'), access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'), ) self.qb_client = QuickBooks(session_manager=self.session_manager, sandbox=True, company_id=os.environ.get('COMPANY_ID')) self.name = "TaxCode {0}".format(datetime.now().strftime('%d%H%M'))
def open_qbo_connection(request): """ Helper function for connecting to QBO, when a view needs an instance of client. Relies on the session containing the access_token, access_token_secret, and company_id. :param request: :return client instance: """ client = QuickBooks( sandbox=True, consumer_key=QUICKBOOKS_CLIENT_KEY, consumer_secret=QUICKBOOKS_CLIENT_SECRET, access_token=request.session['access_token'], access_token_secret=request.session['access_token_secret'], company_id=request.session['realm_id']) return client
def setUp(self): super(QuickbooksUnitTestCase, self).setUp() self.auth_client = AuthClient( client_id='CLIENTID', client_secret='CLIENT_SECRET', environment=Environments.SANDBOX, redirect_uri='http://localhost:8000/callback', ) self.qb_client = QuickBooks( #auth_client=self.auth_client, refresh_token='REFRESH_TOKEN', company_id='COMPANY_ID', ) self.qb_client.sandbox = True
def setUp(self): super(QuickbooksTestCase, self).setUp() self.auth_client = AuthClient( client_id=os.environ.get('CLIENT_ID'), client_secret=os.environ.get('CLIENT_SECRET'), environment=Environments.SANDBOX, redirect_uri='http://localhost:8000/callback', ) self.qb_client = QuickBooks( minorversion=54, auth_client=self.auth_client, refresh_token=os.environ.get('REFRESH_TOKEN'), company_id=os.environ.get('COMPANY_ID'), ) self.qb_client.sandbox = True
def setUp(self): self.session_manager = Oauth1SessionManager( sandbox=True, consumer_key=os.environ.get('CONSUMER_KEY'), consumer_secret=os.environ.get('CONSUMER_SECRET'), access_token=os.environ.get('ACCESS_TOKEN'), access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'), ) self.qb_client = QuickBooks( session_manager=self.session_manager, sandbox=True, company_id=os.environ.get('COMPANY_ID') ) self.account_number = datetime.now().strftime('%d%H%M') self.name = "Test Item {0}".format(self.account_number) self.income_account = Account.where( "AccountType = 'Income' and AccountSubType = 'SalesOfProductIncome'", max_results=1, qb=self.qb_client)[0] self.expense_account = Account.where( "AccountSubType = 'SuppliesMaterialsCogs'", max_results=1, qb=self.qb_client)[0] self.asset_account = Account.where("AccountSubType = 'Inventory'", max_results=1, qb=self.qb_client)[0]