ebay-node-api icon indicating copy to clipboard operation
ebay-node-api copied to clipboard

X-EBAY-API-IAF-TOKEN requirement. Some get requests failing e.g. getShippingCosts & getSingleItem

Open EarthlingDavey opened this issue 2 years ago • 2 comments

Issue

  • [x] Issue
  • [ ] Enhancement / Improvement

Steps to reproduce

Ebay has introduced a new requirement for the token to be set in header property X-EBAY-API-IAF-TOKEN.

See: https://developer.ebay.com/Devzone/shopping/docs/CallRef/GetSingleItem.html

To reproduce, run the example for getShippingCosts and the following error will be shown.

Expected Behavior

No errors, return of shipping cost.

Actual Behavior

error: [
  {
    "ShortMessage": "Token not available in request.",
    "LongMessage": "Token not available in request. Please specify a valid token as HTTP header.",
    "ErrorCode": "1.33",
    "SeverityCode": "Error",
    "ErrorClassification": "RequestError"
  }

I think the update to eBay policy regarding token in the header X-EBAY-API-IAF-TOKEN will have an affect on some other of the functions.

Modify each failing fnction like getShippingCosts to include something

if (!this.options.appAccessToken)
    throw new Error('Missing Access token, Generate access token');
  const auth = 'Bearer ' + this.options.appAccessToken;

  return getRequest(url, auth).then(...

And,

const getRequest = (url, token = undefined) => {
  if (url.includes('http://')) httpRequest = require('http');
  const options = {
    headers: {},
  };
  if (token) {
    options.headers = {
      'X-EBAY-API-IAF-TOKEN': token,
    };
  }
  return new Promise((resolve, reject) => {
    httpRequest.get(url, options, (res) => {...

What do you think is a good solution to this?

EarthlingDavey avatar Nov 14 '21 18:11 EarthlingDavey

It looks like these are both endpoints of the shopping API.

eBay Partner Network will no longer support eBay’s Finding API, Shopping API or Trading API, into the new year. The deadline to migrate off these APIs has come. Today - Email from ebay.

Doh, it looks like a bunch of these functions will no longer work soon. @pajaydev

EarthlingDavey avatar Nov 19 '21 08:11 EarthlingDavey

@EarthlingDavey Got it. Thanks for brining it up. Free feel if you want to make the change and take this over

pajaydev avatar Feb 10 '22 23:02 pajaydev