Search code examples
pythonebay-sdk

ebaysdk: Not being able to connect


I've being trying to use the python ebaysdk and I'm not being able to understand why I keep receiving the following error:

{'Timestamp': '2017-02-21T19:55:31.915Z', 'Errors': {'LongMessage': 'Validation of the authentication token in API request failed.', 'ShortMessage': 'Auth token is invalid.', 'SeverityCode': 'Error', 'ErrorCode': '931', 'ErrorClassification': 'RequestError'}, 'Build': 'E989_CORE_API_18131074_R1', 'Version': '989', 'Ack': 'Failure'}

The code snippet was copied from the github repo (https://github.com/timotheus/ebaysdk-python).

from ebaysdk.trading import Connection as Trading
from ebaysdk.exception import ConnectionError

try:    
    api = Trading(domain='api.sandbox.ebay.com')
    response = api.execute('GetOrders', {})
    print(response.dict())
    print(response.reply)
except ConnectionError as e:
    print(e)
    print(e.response.dict())

I've also put all the configuration in the ebay.yaml file.

To run the code snippet, I go to developers.ebay.com, generate the user authorization token, paste it into the yaml file and run the script.

The idea of my script is to run in background.

Can someone that have experience with ebaysdk show me how to connect correctly to the Trading API?


Solution

  • I've found the issue with this piece of code: I did not have configured the entry for the sandbox in the yaml file. After I did this, it have moved on. I have a new error (will post a question in a few minutes).

    Here is the ebay.yaml:

    # Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
    api.sandbox.ebay.com:
        compatability: 967
        appid: xxxxx
        certid: yyyyy
        devid: zzzzzzz
        username: uuuuu
        password: ppppp
    
    # Trading API - https://www.x.com/developers/ebay/products/trading-api
    api.ebay.com:
        compatability: 967
        appid: xxxxx
        certid: yyyyy
        devid: zzzzzzz