ebaysdk:无法连接

ebaysdk: Not being able to connect

我一直在尝试使用 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 存储库 (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文件里。

为了 运行 代码片段,我转到 developers.ebay.com,生成用户授权令牌,将其粘贴到 yaml 文件和 运行 脚本中。

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

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

我在您的代码片段或加载的模块中没有看到任何对 YAML 配置的引用...按照 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')

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

这里是 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