3

我一直在尝试使用 python ebaysdk,但我无法理解为什么我不断收到以下错误:

{'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'}

代码片段是从 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())

我还将所有配置都放在了 ebay.yaml 文件中。

要运行代码片段,我会访问 developer.ebay.com,生成用户授权令牌,将其粘贴到 yaml 文件中并运行脚本。

我的脚本的想法是在后台运行。

有使用 ebaysdk 经验的人可以告诉我如何正确连接到交易 API 吗?

4

2 回答 2

1

我发现了这段代码的问题:我没有在 yaml 文件中配置沙箱的条目。在我这样做之后,它继续前进。我有一个新错误(将在几分钟内发布一个问题)。

这是 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
于 2017-02-22T00:14:38.957 回答
1

我在您的代码片段或加载的模块中没有看到对 YAML-Configuration 的任何引用......按照https://github.com/timotheus/ebaysdk-python/wiki/Trading-API-Class上的文档,您需要指定 AppId 或保存 ID 的配置文件:

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

或者

api = Trading(config_file='myfile.yaml')
于 2017-02-21T21:20:03.300 回答