Ejemplo n.º 1
0
    def user_consent(self):
        '''Triggers the User Consent OAuth2.0 flow
        in order to retrieve an Authorization Code
        and a Realm ID.
        '''
        auth_client = AuthClient(self.config.get("client_id"),
                                 self.config.get("client_secret"),
                                 self.config.get("redirect_uri"),
                                 self.config.get("environment"))

        scopes = [Scopes.ACCOUNTING]
        auth_url = auth_client.get_authorization_url(scopes)
        webbrowser.open(auth_url)
        auth_code = input('Enter the Authorization Code: ')
        realm_id = input('Enter the Realm ID: ')
        auth_client.get_bearer_token(auth_code, realm_id=realm_id)
        self.config["realm_id"] = realm_id
        self.config["refresh_token"] = auth_client.refresh_token
        self.config[
            "refresh_token_expires_at"] = self._generate_token_expiration(
                auth_client.x_refresh_token_expires_in)

        LOGGER.info('Generating new config..')
        with open(self.args.config_path, 'r+') as f:
            json.dump(self.config, f, indent=2)
Ejemplo n.º 2
0
def openid(request):
    auth_client = AuthClient(
        settings.CLIENT_ID,
        settings.CLIENT_SECRET,
        settings.REDIRECT_URI,
        settings.ENVIRONMENT,
    )

    url = auth_client.get_authorization_url([Scopes.OPENID, Scopes.EMAIL])
    request.session['state'] = auth_client.state_token
    return redirect(url)
Ejemplo n.º 3
0
def oauth():
    auth_client = AuthClient(
        client_id,
        client_secret,
        redirect_uri,
        environment,
    )

    url = auth_client.get_authorization_url([Scopes.ACCOUNTING])
    # request.session['state'] = auth_client.state_token
    return redirect(url)
Ejemplo n.º 4
0
def start_up():
    auth_client = AuthClient(
    cfg.qbo['QBO_CLIENT_ID'],
    cfg.qbo['QBO_CLIENT_SECRET'],
    "https://tdasu.pagekite.me/redirect",
    environment="production"
    )

    scopes = [
        Scopes.ACCOUNTING,
        Scopes.PROFILE,
        Scopes.EMAIL,
        Scopes.OPENID,
        Scopes.ADDRESS,
        Scopes.PHONE
    ]
    auth_url = auth_client.get_authorization_url(scopes)
    print(auth_url)
    result = "<a href=\"" + auth_url + "\">" + auth_url + "</a"
    return result
Ejemplo n.º 5
0
from intuitlib.client import AuthClient
from intuitlib.enums import Scopes
# from quickbooks import Oauth2SessionManager
redirect_uri = "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl"

client_id = "ABGA9WMqhlrmpP39UxG5Q3H2227bLiXsIWVTeoq0UnQVW2B8fw"
client_secret = "risgBjg1RqjqK8AVDHnYmbwnY46vG0K45v6kG3FH"
Environment = "“sandbox”"

# Instantiate client
auth_client = AuthClient(
    client_id,
    client_secret,
    redirect_uri,
    Environment  # “sandbox” or “production”
)

scopes = [
    Scopes.ACCOUNTING,
]

#  Get authorization URL
auth_url = auth_client.get_authorization_url(scopes)
print(auth_url)
# auth_cent.get_bearer_token(auth_code=auth_code,realm_id=realm_id)
# auth_client.get_bearer_token(auth_code, realm_id=realm_id)
Ejemplo n.º 6
0
#[production]
CLIENT_ID= <clientid>
CLIENT_SECRET = <secret>
COMPANY_ID='193514844769229'
REFRESH_TOKEN=<token>
SQUARE_BEARER_TOKEN=<token>


print("authorizing...")
auth_client = AuthClient(
        client_id=CLIENT_ID,
        client_secret=CLIENT_SECRET,
        environment='sandbox',
        redirect_uri='http://localhost:5000/callback',
    )
url = auth_client.get_authorization_url(scopes=[Scopes.ACCOUNTING])
print("finished authorizing...")

print('running api call...' + url)

client = QuickBooks(
         auth_client=auth_client,
         refresh_token=REFRESH_TOKEN,
         company_id=COMPANY_ID,
     )
print('finished connecting')

last_year_sales = SalesReceipt.query(f"SELECT * FROM salesreceipt where TxnDate > '2018-12-01' and TxnDate < '2019-06-01' MAXRESULTS 1000", qb=client)
last_years_customer_sales = {}

#print(f"Scout, Customer, Phone, Email")