Walter_Ritzel
Walter_Ritzel

Reputation: 1397

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?

Upvotes: 3

Views: 846

Answers (2)

Walter_Ritzel
Walter_Ritzel

Reputation: 1397

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

Upvotes: 1

N. Groß
N. Groß

Reputation: 21

I don't see any reference to the YAML-Configuration in your code snippet or in the loaded modules... Following the documentation at https://github.com/timotheus/ebaysdk-python/wiki/Trading-API-Class, you either need to specify the AppId or the config file in which the ID is saved:

api = Trading(appid="YOUR_APPID", devid="YOUR_DEVID", certid="YOUR_CERTID", token="YOUR_AUTH_TOKEN")

or

api = Trading(config_file='myfile.yaml')

Upvotes: 1

Related Questions