ebay-oauth-nodejs-client
ebay-oauth-nodejs-client copied to clipboard
Unable to use sandbox environment
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);
})();
@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.
})
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.
@kamajigames have you got the resolution? I am still stuck with the same issue
@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)
});
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.