1

这是特定于 walmart api 的。我觉得好像我准确地配置了标头并根据文档要求提供了所需的标头。但是,我仍然收到 403 错误。当我在邮递员中测试时,我仍然收到一个 403 错误,它提到服务器拒绝了一个有效的请求。这是下面记录的数据。我在后端使用了带有 axios 和 crypto-js 库的 Node.js。谁能让我知道这里有什么问题?请让我知道是否还有其他我应该添加到问题中的内容。(我故意删除了消费者 ID 值):

开始 Walmart API 调用...

[0] Error: Request failed with status code 403
[0]     at createError (C:\Projects\node_modules\axios\lib\core\createError.js:16:15)
[0]     at settle (C:\Projects\node_modules\axios\lib\core\settle.js:17:12)
[0]     at Unzip.handleStreamEnd (C:\Projects\node_modules\axios\lib\adapters\http.js:260:11)
[0]     at Unzip.emit (events.js:400:28)
[0]     at Unzip.emit (domain.js:470:12)
[0]     at endReadableNT (internal/streams/readable.js:1317:12)
[0]     at processTicksAndRejections (internal/process/task_queues.js:82:21) {
[0]   config: {
[0]     url: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0]     method: 'get',
[0]     headers: {
[0]       Accept: 'application/json, text/plain, */*',
[0]       'WM_SEC.KEY_VERSION': '1',
[0]       'WM_SEC.TIMESTAMP': '1630376129289',
[0]       'WM_SEC.AUTH_SIGNATURE': [Promise],
[0]       'WM_CONSUMER.ID': '',
[0]       'User-Agent': 'axios/0.21.1'
[0]     },
[0]     transformRequest: [ [Function: transformRequest] ],
[0]     transformResponse: [ [Function: transformResponse] ],
[0]     timeout: 0,
[0]     adapter: [Function: httpAdapter],
[0]     xsrfCookieName: 'XSRF-TOKEN',
[0]     xsrfHeaderName: 'X-XSRF-TOKEN',
[0]     maxContentLength: -1,
[0]     maxBodyLength: -1,
[0]     validateStatus: [Function: validateStatus],
[0]     data: undefined
[0]   },
[0]   request: <ref *1> ClientRequest {
[0]     _events: [Object: null prototype] {
[0]       abort: [Function (anonymous)],
[0]       aborted: [Function (anonymous)],
[0]       connect: [Function (anonymous)],
[0]       error: [Function (anonymous)],
[0]       socket: [Function (anonymous)],
[0]       timeout: [Function (anonymous)],
[0]       prefinish: [Function: requestOnPrefinish]
[0]     },
[0]     _eventsCount: 7,
[0]     _maxListeners: undefined,
[0]     outputData: [],
[0]     outputSize: 0,
[0]     writable: true,
[0]     destroyed: true,
[0]     _last: true,
[0]     chunkedEncoding: false,
[0]     shouldKeepAlive: false,
[0]     _defaultKeepAlive: true,
[0]     useChunkedEncodingByDefault: false,
[0]     sendDate: false,
[0]     _removedConnection: false,
[0]     _removedContLen: false,
[0]     _removedTE: false,
[0]     _contentLength: 0,
[0]     _hasBody: true,
[0]     _trailer: '',
[0]     finished: true,
[0]     _headerSent: true,
[0]     socket: TLSSocket {
[0]       _tlsOptions: [Object],
[0]       _secureEstablished: true,
[0]       _securePending: false,
[0]       _newSessionPending: false,
[0]       _controlReleased: true,
[0]       secureConnecting: false,
[0]       _SNICallback: null,
[0]       servername: 'developer.api.walmart.com',
[0]       alpnProtocol: false,
[0]       authorized: true,
[0]       authorizationError: null,
[0]       encrypted: true,
[0]       _events: [Object: null prototype],
[0]       _eventsCount: 12,
[0]       connecting: false,
[0]       _hadError: false,
[0]       _parent: null,
[0]       _host: 'developer.api.walmart.com',
[0]       _readableState: [ReadableState],
[0]       _maxListeners: undefined,
[0]       _writableState: [WritableState],
[0]       allowHalfOpen: false,
[0]       _sockname: null,
[0]       _pendingData: null,
[0]       _pendingEncoding: '',
[0]       server: undefined,
[0]       _server: null,
[0]       ssl: null,
[0]       _requestCert: true,
[0]       _rejectUnauthorized: true,
[0]       parser: null,
[0]       _httpMessage: [Circular *1],
[0]       write: [Function: writeAfterFIN],
[0]       [Symbol(res)]: null,
[0]       [Symbol(verified)]: true,
[0]       [Symbol(pendingSession)]: null,
[0]       [Symbol(async_id_symbol)]: 124,
[0]       [Symbol(kHandle)]: null,
[0]       [Symbol(kSetNoDelay)]: false,
[0]       [Symbol(lastWriteQueueSize)]: 0,
[0]       [Symbol(timeout)]: null,
[0]       [Symbol(kBuffer)]: null,
[0]       [Symbol(kBufferCb)]: null,
[0]       [Symbol(kBufferGen)]: null,
[0]       [Symbol(kCapture)]: false,
[0]       [Symbol(kBytesRead)]: 715,
[0]       [Symbol(kBytesWritten)]: 340,
[0]       [Symbol(connect-options)]: [Object],
[0]       [Symbol(RequestTimeout)]: undefined
[0]     },
[0]     _header: 'GET /api-proxy/service/affil/product/v2/paginated/items HTTP/1.1\r\n' +
[0]       'Accept: application/json, text/plain, */*\r\n' +
[0]       'WM_SEC.KEY_VERSION: 1\r\n' +
[0]       'WM_SEC.TIMESTAMP: 1630376129289\r\n' +
[0]       'WM_SEC.AUTH_SIGNATURE: [object Promise]\r\n' +
[0]       'WM_CONSUMER.ID: ...\r\n' +
[0]       'User-Agent: axios/0.21.1\r\n' +
[0]       'Host: developer.api.walmart.com\r\n' +
[0]       'Connection: close\r\n' +
[0]       '\r\n',
[0]     _keepAliveTimeout: 0,
[0]     _onPendingData: [Function: noopPendingOutput],
[0]     agent: Agent {
[0]       _events: [Object: null prototype],
[0]       _eventsCount: 2,
[0]       _maxListeners: undefined,
[0]       defaultPort: 443,
[0]       protocol: 'https:',
[0]       options: [Object],
[0]       requests: {},
[0]       sockets: {},
[0]       freeSockets: {},
[0]       keepAliveMsecs: 1000,
[0]       keepAlive: false,
[0]       maxSockets: Infinity,
[0]       maxFreeSockets: 256,
[0]       scheduling: 'lifo',
[0]       maxTotalSockets: Infinity,
[0]       totalSocketCount: 0,
[0]       maxCachedSessions: 100,
[0]       _sessionCache: [Object],
[0]       [Symbol(kCapture)]: false
[0]     },
[0]     socketPath: undefined,
[0]     method: 'GET',
[0]     maxHeaderSize: undefined,
[0]     insecureHTTPParser: undefined,
[0]     path: '/api-proxy/service/affil/product/v2/paginated/items',
[0]     _ended: true,
[0]     res: IncomingMessage {
[0]       _readableState: [ReadableState],
[0]       _events: [Object: null prototype],
[0]       _eventsCount: 1,
[0]       _maxListeners: undefined,
[0]       socket: [TLSSocket],
[0]       httpVersionMajor: 1,
[0]       httpVersionMinor: 1,
[0]       httpVersion: '1.1',
[0]       complete: true,
[0]       headers: [Object],
[0]       rawHeaders: [Array],
[0]       trailers: {},
[0]       rawTrailers: [],
[0]       aborted: false,
[0]       upgrade: false,
[0]       url: '',
[0]       method: null,
[0]       statusCode: 403,
[0]       statusMessage: 'Forbidden',
[0]       client: [TLSSocket],
[0]       _consuming: true,
[0]       _dumped: false,
[0]       req: [Circular *1],
[0]       responseUrl: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0]       redirects: [],
[0]       [Symbol(kCapture)]: false,
[0]       [Symbol(RequestTimeout)]: undefined
[0]     },
[0]     aborted: false,
[0]     timeoutCb: null,
[0]     upgradeOrConnect: false,
[0]     parser: null,
[0]     maxHeadersCount: null,
[0]     reusedSocket: false,
[0]     host: 'developer.api.walmart.com',
[0]     protocol: 'https:',
[0]     _redirectable: Writable {
[0]       _writableState: [WritableState],
[0]       _events: [Object: null prototype],
[0]       _eventsCount: 2,
[0]       _maxListeners: undefined,
[0]       _options: [Object],
[0]       _ended: true,
[0]       _ending: true,
[0]       _redirectCount: 0,
[0]       _redirects: [],
[0]       _requestBodyLength: 0,
[0]       _requestBodyBuffers: [],
[0]       _onNativeResponse: [Function (anonymous)],
[0]       _currentRequest: [Circular *1],
[0]       _currentUrl: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0]       [Symbol(kCapture)]: false
[0]     },
[0]     [Symbol(kCapture)]: false,
[0]     [Symbol(kNeedDrain)]: false,
[0]     [Symbol(corked)]: 0,
[0]     [Symbol(kOutHeaders)]: [Object: null prototype] {
[0]       accept: [Array],
[0]       'wm_sec.key_version': [Array],
[0]       'wm_sec.timestamp': [Array],
[0]       'wm_sec.auth_signature': [Array],
[0]       'wm_consumer.id': [Array],
[0]       'user-agent': [Array],
[0]       host: [Array]
[0]     }
[0]   },
[0]   response: {
[0]     status: 403,
[0]     statusText: 'Forbidden',
[0]     headers: {
[0]       'content-type': 'application/json;charset=utf-8',
[0]       'last-modified': 'Tue, 31 Aug 2021 02:18:31 GMT',
[0]       'strict-transport-security': 'max-age=86400',
[0]       'wm_svc.env': 'prod',
[0]       'wm_svc.name': 'affil-product',
[0]       'wm_svc.version': '2.0.0',
[0]       'x-lua-strict-transport-security': 'max-age=86400',
[0]       'x-tb': '1',
[0]       'x-tb-optimization-total-bytes-saved': '0',
[0]       date: 'Tue, 31 Aug 2021 02:18:31 GMT',
[0]       connection: 'close',
[0]       'set-cookie': [Array]
[0]     },
[0]     config: {
[0]       url: 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/paginated/items',
[0]       method: 'get',
[0]       headers: [Object],
[0]       transformRequest: [Array],
[0]       transformResponse: [Array],
[0]       timeout: 0,
[0]       adapter: [Function: httpAdapter],
[0]       xsrfCookieName: 'XSRF-TOKEN',
[0]       xsrfHeaderName: 'X-XSRF-TOKEN',
[0]       maxContentLength: -1,
[0]       maxBodyLength: -1,
[0]       validateStatus: [Function: validateStatus],
[0]       data: undefined
[0]     },
[0]     request: <ref *1> ClientRequest {
[0]       _events: [Object: null prototype],
[0]       _eventsCount: 7,
[0]       _maxListeners: undefined,
[0]       outputData: [],
[0]       outputSize: 0,
[0]       writable: true,
[0]       destroyed: true,
[0]       _last: true,
[0]       chunkedEncoding: false,
[0]       shouldKeepAlive: false,
[0]       _defaultKeepAlive: true,
[0]       useChunkedEncodingByDefault: false,
[0]       sendDate: false,
[0]       _removedConnection: false,
[0]       _removedContLen: false,
[0]       _removedTE: false,
[0]       _contentLength: 0,
[0]       _hasBody: true,
[0]       _trailer: '',
[0]       finished: true,
[0]       _headerSent: true,
[0]       socket: [TLSSocket],
[0]       _header: 'GET /api-proxy/service/affil/product/v2/paginated/items HTTP/1.1\r\n' +
[0]         'Accept: application/json, text/plain, */*\r\n' +
[0]         'WM_SEC.KEY_VERSION: 1\r\n' +
[0]         'WM_SEC.TIMESTAMP: 1630376129289\r\n' +
[0]         'WM_SEC.AUTH_SIGNATURE: [object Promise]\r\n' +
[0]         'WM_CONSUMER.ID: 0ea59601-ea5c-448b-9003-d1baea61e4d6\r\n' +
[0]         'User-Agent: axios/0.21.1\r\n' +
[0]         'Host: developer.api.walmart.com\r\n' +
[0]         'Connection: close\r\n' +
[0]         '\r\n',
[0]       _keepAliveTimeout: 0,
[0]       _onPendingData: [Function: noopPendingOutput],
[0]       agent: [Agent],
[0]       socketPath: undefined,
[0]       method: 'GET',
[0]       maxHeaderSize: undefined,
[0]       insecureHTTPParser: undefined,
[0]       path: '/api-proxy/service/affil/product/v2/paginated/items',
[0]       _ended: true,
[0]       res: [IncomingMessage],
[0]       aborted: false,
[0]       timeoutCb: null,
[0]       upgradeOrConnect: false,
[0]       parser: null,
[0]       maxHeadersCount: null,
[0]       reusedSocket: false,
[0]       host: 'developer.api.walmart.com',
[0]       protocol: 'https:',
[0]       _redirectable: [Writable],
[0]       [Symbol(kCapture)]: false,
[0]       [Symbol(kNeedDrain)]: false,
[0]       [Symbol(corked)]: 0,
[0]       [Symbol(kOutHeaders)]: [Object: null prototype]
[0]     },
[0]     data: { details: [Object] }
[0]   },
[0]   isAxiosError: true,
[0]   toJSON: [Function: toJSON] 
4

0 回答 0