eBay / ebay-oauth-nodejs-client

🔑 Generate an OAuth token that can be used to call the eBay Developer REST APIs.
https://ebay.github.io/ebay-oauth-nodejs-client/
Apache License 2.0
64 stars 30 forks source link

Unable to use sandbox environment #11

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi there,

When attempting to fetch a token using the sandbox environment, the lib throws an error:

const encodedStr = base64Encode(`${ebayAuthToken.clientId}:${ebayAuthToken.clientSecret}`);
                                                     ^

TypeError: Cannot read property 'clientId' of undefined

Code I'm using w/ my sandbox creds:

const EbayAuthToken = require('ebay-oauth-nodejs-client');

const ebayAuthToken = new EbayAuthToken({
  clientId: '',
  clientSecret: '',
  redirectUri: '',
});

(async () => {
  const token = await ebayAuthToken.getApplicationToken('SANDBOX');
  console.log(token);
})();
auctus10 commented 3 years ago

@kamajigames You need to give a filepath to your config.json.

Like this -

const EbayAuthToken = require('ebay-oauth-nodejs-client');
const ebayAuthToken = new EbayAuthToken({
    filePath: 'demo/eBayJson.json' // input file path.
})
NFNChris commented 3 years ago

Although not depicted in the example code, the "env" configuration parameter ('PRODUCTION' or 'SANDBOX') is required along with clientId, clientSecret, and redirectUri. If it's not specified, the module defaults to "PRODUCTION" which is why it won't work with the sandbox environment.

sarmadfolio3 commented 2 years ago

@kamajigames have you got the resolution? I am still stuck with the same issue

poewt commented 1 year ago

@kamajigames have you got the resolution? I am still stuck with the same issue

Like @NFNChris mentioned try adding "env" to your EbayAuthToken like so:

const ebayAuthToken = new EbayAuthToken({
  clientId: '',
  clientSecret: '',
  redirectUri: '',
  env: 'SANDBOX', // (or PRODUCTION)
});
jauntyjocularjay commented 3 months ago

I added clarification on this issue to the Readme, hoping to make it more explicit. I cannot create a pull request as I am not a collaborator. The clarification can be found here.