GithubHelp home page GithubHelp logo

Comments (2)

dantio avatar dantio commented on May 20, 2024

We also using Express as Backend. I don't know what exactly is the error. Here is how we do the call, maybe it helps:

const eBay = new eBayApi({
  // ....
  scope: [
          'https://api.ebay.com/oauth/api_scope',
          'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.marketing',
          'https://api.ebay.com/oauth/api_scope/sell.inventory.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.inventory',
          'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.account',
          'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
          'https://api.ebay.com/oauth/api_scope/sell.analytics.readonly',
          'https://api.ebay.com/oauth/api_scope/sell.finances',
          'https://api.ebay.com/oauth/api_scope/sell.payment.dispute',
          'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly'
        ]
});

const token = await getFromDb(); // get the token that was created in the ebay sign in process
eBay.setCredentials(token);

// Listen to refresh token event, and update the token in the DB
eBay.OAuth2.on('refreshAuthToken', (token: any) => {
      storeInDb(token).then(() => console.log('token is stored'))
});

eBay.sell.fulfillment.getOrders({
  limit: 5
}).then(order => {
  console.log('order', JSON.stringify(order, null, 2));
}).catch(e => {
  console.error(JSON.stringify(e, null, 2));
});

Check if you always use the same scope for sign in and API request.
You have to generate the first token with all scopes you need for you app.
If you add a new scopes later and use a token that was not authorized with this scope, it will not work!
I'm sure that refreshing the token will also not help. You have to obtain the token already with all required scopes!

Btw. You don't need to refresh it manually. It's done automatically. You can listen to the event and store the token (as shown in the example above)

from ebay-api.

doverradio avatar doverradio commented on May 20, 2024

Thank you, it completely works now for me. In the end, it was passing in the original complete token object that solved it...

  let user = await User.findById({_id})
  
  // set OAuth2 eBay credentials
  eBay.auth.oAuth2.setCredentials(user.token[0])

from ebay-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.