ej2 / python-quickbooks

A Python library for accessing the Quickbooks API.
MIT License
401 stars 194 forks source link

Error message from example code #71

Closed alexanderwhatley closed 7 years ago

alexanderwhatley commented 7 years ago

I'm getting an error message using the example code:

Traceback (most recent call last):
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1994, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/alexander/Documents/Programming/QBTest/app.py", line 41, in access_qb
    client.get_access_tokens(request.args['oauth_verifier'])
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/quickbooks/client.py", line 202, in get_access_tokens
    data={'oauth_verifier': oauth_verifier})
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/rauth/service.py", line 359, in get_auth_session
    **kwargs)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/rauth/service.py", line 332, in get_access_token
    process_token_request(r, decoder, key_token, key_token_secret)
  File "/home/alexander/anaconda3/lib/python3.5/site-packages/rauth/service.py", line 24, in process_token_request
    raise KeyError(PROCESS_TOKEN_ERROR.format(key=bad_key, raw=r.content))
KeyError: "Decoder failed to handle oauth_token with data as returned by provider. A different decoder may be needed. Provider returned: b'oauth_problem=parameter_absent&oauth_parameters_absent=oauth_token'"

The code I am using is below (I'm using Flask):

from flask import Flask, render_template, request
from quickbooks import QuickBooks

app = Flask(__name__)
QUICKBOOKS_CLIENT_KEY = "..my client key..."
QUICKBOOKS_CLIENT_SECRET = "...my client secret..."
CALLBACK_URL = 'http://localhost:5000/qbauth'
authorize_url, request_token, request_token_secret = None, None, None

@app.route('/')
def start_qb():
    print("START QB")
    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
    print("REQUEST TOKENS: {} {} {}".format(authorize_url, request_token, request_token_secret))
    return authorize_url

@app.route('/qbauth')
def access_qb():
    print("QB AUTH")
    client = QuickBooks(
        sandbox=True,
        consumer_key=QUICKBOOKS_CLIENT_KEY,
        consumer_secret=QUICKBOOKS_CLIENT_SECRET
    )

    client.authorize_url = authorize_url
    client.request_token = request_token
    client.request_token_secret = request_token_secret
    client.set_up_service()
    print("SET UP SERVICE")
    print(request.args)
    client.get_access_tokens(request.args['oauth_verifier'])

    realm_id = request.args['realmId']
    access_token = client.access_token
    access_token_secret = client.access_token_secret
    print(realm_id, access_token, access_token_secret)
    return "Hello World"

if __name__ == "__main__":
    app.run(debug = True, reloader_type='stat')
deathnfudge commented 7 years ago

Were you able to get the example working?