ebaysdk-python 身份验证失败:无效的应用程序

ebaysdk-python Authentication failed : Invalid Application

我正在尝试使用 python 脚本连接 ebay。这是我的代码,我用过 ebaysdk-python

import ebaysdk
from ebaysdk.finding import Connection as finding
from ebaysdk.exception import ConnectionError

try:

    api = finding(debug=True, config_file='myebay.yaml',)
    api_request = {
            'Keywords':'Harry Potter',
            'MaxEntries': 2,
            'AvailableItemsOnly':True,
    }

    response = api.execute('findItemsAdvanced', api_request)
    print response

except ConnectionError as e:
    print "\n\n\n",e
    print "\n\n\n",e.response.dict()

而 运行 这是我遇到的错误。这是调试结果

2015-08-25 12:24:18,101 ebaysdk [DEBUG]:execute: verb=findItemsAdvanced data={'Keywords': 'Harry Potter', 'MaxEntries': 2, 'AvailableItemsOnly': True}
2015-08-25 12:24:18,107 ebaysdk [DEBUG]:REQUEST (cb3019a4-1f9a-4e82-9ba9-b45ed84329dd): POST http://svcs.ebay.com/services/search/FindingService/v1
2015-08-25 12:24:18,107 ebaysdk [DEBUG]:headers=CaseInsensitiveDict({'X-EBAY-SOA-GLOBAL-ID': 'EBAY-US', 'Content-Length': '254', 'X-EBAY-SOA-SECURITY-APPNAME': u'test-08c4-473a-8461-415f8024798f', 'X-EBAY-SOA-OPERATION-NAME': 'findItemsAdvanced', 'X-EBAY-SOA-SERVICE-NAME': 'FindingService', 'X-EBAY-SOA-SERVICE-VERSION': u'1.0.0', 'User-Agent': 'eBaySDK/2.1.2 Python/2.7.6 Linux/3.16.0-46-generic', 'X-EBAY-SDK-REQUEST-ID': 'cb3019a4-1f9a-4e82-9ba9-b45ed84329dd', 'X-EBAY-SOA-RESPONSE-DATA-FORMAT': 'XML', 'X-EBAY-SOA-REQUEST-DATA-FORMAT': 'XML', 'Content-Type': 'text/xml'})
2015-08-25 12:24:18,107 ebaysdk [DEBUG]:body=<?xml version='1.0' encoding='utf-8'?><findItemsAdvancedRequest xmlns="http://www.ebay.com/marketplace/search/v1/services"><AvailableItemsOnly>True</AvailableItemsOnly><Keywords>Harry Potter</Keywords><MaxEntries>2</MaxEntries></findItemsAdvancedRequest>
2015-08-25 12:24:18,809 ebaysdk [DEBUG]:RESPONSE (cb3019a4-1f9a-4e82-9ba9-b45ed84329dd):
2015-08-25 12:24:18,809 ebaysdk [DEBUG]:elapsed time=0:00:00.701135
2015-08-25 12:24:18,809 ebaysdk [DEBUG]:status code=500
2015-08-25 12:24:18,809 ebaysdk [DEBUG]:headers=CaseInsensitiveDict({'x-ebay-soa-global-id': 'EBAY-US', 'x-ebay-request-id': '14f63a2c-ffb0-a7ea-3304-9134ce2175ca!services.search.FindingService.v1!10.126.163.48!fndngesb[]', 'x-cnection': 'close', 'x-ebay-soa-operation-name': 'findItemsAdvanced', 'transfer-encoding': 'chunked', 'x-ebay-soa-error-response': 'TRUE', 'x-ebay-soa-service-name': '{http://www.ebay.com/marketplace/search/v1/services}FindingService', 'x-ebay-soa-service-version': '1.13.0', 'server': 'Apache-Coyote/1.1', 'x-ebay-soa-locale-list': 'en-US_US', 'x-ebay-soa-message-protocol': 'NONE', 'date': 'Tue, 25 Aug 2015 06:54:17 GMT', 'x-ebay-soa-request-id': '14f63a2d-0360-a7ed-d744-9224fd474628!FindingService!10.126.221.116!v3apifindingcore[]', 'guid': '14f63a2c-ffb0-a7ea-3304-9134ce2175ca', 'content-type': 'text/xml;charset=UTF-8', 'x-ebay-soa-response-data-format': 'XML', 'x-ebay-soa-service-metrics': '4251324'})
2015-08-25 12:24:18,809 ebaysdk [DEBUG]:content=<?xml version='1.0' encoding='UTF-8'?><errorMessage xmlns="http://www.ebay.com/marketplace/search/v1/services"><error><errorId>11002</errorId><domain>Security</domain><severity>Error</severity><category>System</category><message>Authentication failed : Invalid Application: test-08c4-473a-8461-415f8024798f</message><subdomain>Authentication</subdomain><parameter name="Param1">Invalid Application: test-08c4-473a-8461-415f8024798f</parameter></error></errorMessage>
2015-08-25 12:24:18,810 ebaysdk [ERROR]:findItemsAdvanced: Internal Server Error, Domain: Security, Severity: Error, errorId: 11002, Authentication failed : Invalid Application: test-08c4-473a-8461-415f8024798f



u'findItemsAdvanced: Internal Server Error, Domain: Security, Severity: Error, errorId: 11002, Authentication failed : Invalid Application: test-08c4-473a-8461-415f8024798f'



{'errorMessage': {'error': {'category': 'System', 'domain': 'Security', 'severity': 'Error', 'message': 'Authentication failed : Invalid Application: test-08c4-473a-8461-415f8024798f', 'subdomain': 'Authentication', 'parameter': {'value': 'Invalid Application: test-08c4-473a-8461-415f8024798f', '_name': 'Param1'}, 'errorId': '11002'}}}

猜对了吗?我缺少什么?

提前致谢。

您正在通过生产环境调用 ebay api。您需要使用沙盒凭据进行调用。您的凭据可能是正确的,但您需要更改域。 ebaysdk-python api默认调用生产环境。

通过在域中传递 ebay 沙箱端点来更改行。

api = finding(domain='svcs.sandbox.ebay.com', debug=True, config_file='myebay.yaml')

它会给你响应Ack Success,

希望对您有所帮助。