madeddie / python-bunq

Thin wrapper around the bunq API
MIT License
10 stars 2 forks source link

Incompatible with jsonpickle #7

Closed OGKevin closed 7 years ago

OGKevin commented 7 years ago

Hey madeddie,

The API class raises ImportError when it gets decoded with jsonpickle. For more information you can see the jsonpickle/jsonpickle#171 issue I've opened on the jsonpickle repo.

OGKevin commented 7 years ago

The cause of the issue has been found https://github.com/jsonpickle/jsonpickle/issues/171#issuecomment-299224806, however this will break the wrapper. So was wondering if you could implement the more lightweight crypto library you were talking about to see if this can fix the issue.

I've changed the code to use RSA.importKey(privkey_pem) but this doesn't work and will give the following error:

Traceback (most recent call last):
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/venv/lib/python3.5/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/BunqAPI/views.py", line 146, in API
    r = getattr(API, selector)()
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/BunqAPI/callbacks.py", line 49, in start_session
    r = self.bunq_api.query('session-server', {'secret': self.api_key})  # noqa
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/BunqAPI/pythonBunq/bunq.py", line 104, in query
    headers['X-Bunq-Client-Signature'] = self.sign(msg)
  File "/Users/KevinH/Desktop/Money-Web-app/BunqWebApp/BunqAPI/pythonBunq/bunq.py", line 127, in sign
    hashes.SHA256()
TypeError: sign() takes 3 positional arguments but 4 were given