Error upgrading to Python dwolla 2.3.0

(Jon Renaut (Cold Ants Properties)) #1

I’m upgrading from Python dwolla 2.2 to 2.3 and getting an error in oauth.get in the sandbox. I haven’t made any changes to my code yet, I was just testing things that were working fine with 2.2


File "/usr/local/lib/python2.7/site-packages/django/core/handlers/" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/" in _legacy_get_response
  249.             response = self._get_response(request)

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/code/coldants/pay/" in auth_redirect
  130. 		info = oauth.get(code, redirect=redirect_url)

File "/usr/local/lib/python2.7/site-packages/dwolla/" in get
  69.     return r._post_without_token('/token/', p, kwargs, custompostfix='/oauth/v2')

File "/usr/local/lib/python2.7/site-packages/dwolla/" in _post_without_token
  82.                 print("dwolla-python: An error has occurred while making a POST request:\n" + '\n'.join(e.args))

Exception Type: TypeError at /pay/auth_redirect/
Exception Value: sequence item 0: expected string, ProtocolError found

Here’s the specific error:
custompostfix: '/oauth/v2’
e: ConnectionError(ProtocolError(‘Connection aborted.’, gaierror(-2, ‘Name or service not known’)),)
endpoint: '/token/‘
kwargs: {}
params: {‘client_id’: ‘MY CLIENT ID’,
‘client_secret’: ‘MY CLIENT SECRET’,
‘code’: u’MY CODE’,
‘grant_type’: ‘authorization_code’,
‘redirect_uri’: ‘http://localhost:8888/pay/auth_redirect/’}
self: < object at 0x7f41bc9f76d0>

Regression in python 2.3.0 prevents me from upgrading from 2.2.1 before the Dec 4th deadline
(Jon Renaut (Cold Ants Properties)) #2

After rebooting the dev server I’m getting an error I got previously - there’s no ‘Success’ key in the response dict:
r: {u’_links’: {u’account’: {u’href’: u’[XXX]}},
u’access_token’: u’MY ACCESS TOKEN’,
u’account_id’: u’MY ACCOUNT ID’,
u’expires_in’: Decimal(‘3602’),
u’refresh_expires_in’: Decimal(‘5184002’),
u’refresh_token’: u’MY REFRESH TOKEN’,
u’scope’: u’send|scheduled|funding|request|transactions’,
u’token_type’: u’bearer’}
response : u’{"_links":{“account”:{“href”:“ ACCOUNT ID”}},“access_token”:“MY ACCESS TOKEN”,“expires_in”:3602,“refresh_token”:“MY REFRESH TOKEN”,“refresh_expires_in”:5184002,“token_type”:“bearer”,“scope”:“send|scheduled|funding|request|transactions”,“account_id”:“MY ACCOUNT ID”}'

(Spencer Hunter) #3

@coldants, This may be a configuration issue. What do you have set as your host value? do you have sandbox_host = ''

(Jon Renaut (Cold Ants Properties)) #4

Yes, I’m not overriding that and I have sandbox set to True. The only other constants I’m overriding are client_secret and client_id

(Jon Renaut (Cold Ants Properties)) #5

@spencer - anything further on this? I would very much like my website to continue working after 12/4 but I can’t put 2.3 into production when almost nothing works in the sandbox.

(Jon Renaut (Cold Ants Properties)) #6

So here is a snippet from your examples section that will demonstrate an error in dwolla-python 2.3

I’m running that code in a virtualenv with just dwolla-python 2.3 installed, and it’s looking for a key that’s not in the response.

Traceback (most recent call last):
  File "", line 23, in <module>
    access_set = oauth.get("Z/KHDIyWO/LboIGn3wGGs1+sRWg=")
  File "/home/jrenaut/src/dwollatest2/lib/python2.7/site-packages/dwolla/", line 69, in get
    return r._post_without_token('/token/', p, kwargs, custompostfix='/oauth/v2')
  File "/home/jrenaut/src/dwollatest2/lib/python2.7/site-packages/dwolla/", line 84, in _post_without_token
    return self._parse(resp.text, kwargs.pop('dwollaparse', 'dwolla'))
  File "/home/jrenaut/src/dwollatest2/lib/python2.7/site-packages/dwolla/", line 55, in _parse
    if r['Success'] is not True:
KeyError: 'Success'

(Spencer Hunter) #7

@coldants, Thanks for sharing your gist. I wasn’t able to recreate the issue, however I believe oauth.get requires you to pass in a redirect_uri which should match the value that was used in the oauth.genauthurl() request. Something like:

access_set = oauth.get("Z/KHDIyWO/LboIGn3wGGs1+sRWg=", "")

(Jon Renaut (Cold Ants Properties)) #8

@spencer I think it used to but no longer:

Traceback (most recent call last):
  File "", line 23, in <module>
    access_set = oauth.get("Z/KHDIyWO/LboIGn3wGGs1+sRWg=", "")
TypeError: get() takes exactly 1 argument (2 given)

Do I have some bad settings? The gist is the only code I wrote. It’s a new virtualenv, Python 2.7, all I did was pip install dwolla. Here’s the output from pip freeze: