Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 2 tasks
EarthlingDavey opened this issue Nov 14, 2021 · 2 comments

Comments

@EarthlingDavey
Copy link
Contributor

Issue

  • 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
Copy link
Contributor Author

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

@pajaydev
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants