ebay-oauth-nodejs-client icon indicating copy to clipboard operation
ebay-oauth-nodejs-client copied to clipboard

Unable to use sandbox environment

Open ghost opened this issue 4 years ago • 5 comments

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);
})();

ghost avatar May 06 '21 14:05 ghost

@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.
})

auctus10 avatar Jun 22 '21 08:06 auctus10

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.

NFNChris avatar Sep 08 '21 16:09 NFNChris

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

sarmadfolio3 avatar Feb 10 '22 13:02 sarmadfolio3

@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)
});

poewt avatar Aug 03 '23 19:08 poewt

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.

jauntyjocularjay avatar Jun 28 '24 23:06 jauntyjocularjay