Search code examples
pythonaweber

Python AWeber API throws Exception: Combination of timestmap, nonce, consumer_key must be unique


I am using Python's AWeber API (https://github.com/aweber/AWeber-API-Python-Library), and I frequently get these exceptions. I have no idea why this happens. Any ideas?

File "/<path>/aweber_api/entry.py", line 160, in __getattr__
    return self._child_collection(attr)

File "/<path>/aweber_api/entry.py", line 151, in _child_collection
    self._child_collections[attr] = self.load_from_url(url)

File "/<path>/aweber_api/base.py", line 38, in load_from_url
    response = self.adapter.request('GET', url)

File "/<path>/aweber_api/oauth.py", line 60, in request
    '{0}: {1}'.format(error_type, error_msg))

APIException: UnauthorizedError: Combination of nonce, timestamp, and consumer_key must be unique. https://labs.aweber.com/docs/troubleshooting#unauthorized

Solution

  • The error message is actually due to OAuth. You are sending the same request multiple times. You need to generate your request again (even if the same command and parameters) to get a new timestamp and nonce.

    This is an OAuth measure to ensure it isn't dealing with the exact same request multiple times. e.g. your program actually sends the command twice at the exact same time.