hendt/ebay-api

get error Token not available in request. Please specify a valid token as HTTP header.

123bistami opened this issue · 10 comments

my code

const eBay = new eBayApi({
        appId: 'XXXXXXXXXXXXXXXXXX',
        certId: 'XXXXXXXXXXXXXXXXXX',
        devId: 'XXXXXXXXXXXXXXXXXX',
        authToken: 'XXXXXXXXXXXXXXXXXX',
        siteId: eBayApi.SiteId.EBAY_DE,
        marketplaceId: eBayApi.MarketplaceId.EBAY_DE,
        sandbox: false
    });

(async () => {
        const result = await eBay.shopping.GetUserProfile({
            UserID: 'xxxxx',
            IncludeSelector: 'Details'
        });

        console.log(result);
    })()

response is

description: 'Token not available in request. Please specify a valid token as HTTP header.',
  meta: {
    Timestamp: '2022-08-14T12:08:53.414Z',
    Ack: 'Failure',
    Errors: {
      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'
    },
    Build: 'E1199_CORE_APILW_19146596_R1',
    Version: 1199,
    [Symbol(raw-error)]: {
      Timestamp: '2022-08-14T12:08:53.414Z',
      Ack: 'Failure',
      Errors: {
        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'
      },
      Build: 'E1199_CORE_APILW_19146596_R1',
      Version: 1199
    }
  }
}

i had inserted a static token, ebay API explorer call works fine, pls help!

authToken is used for the traditional Auth'N'Auth method.
I think you are looking for:

eBay.OAuth2.setCredentials('XXXXXXXXXXXXXXXXXX');
// This token can be seen in the eBay API explorer.

what was the issue?

If you are only using the traditional API, you can use the Auth'n'Auth Token. It is valid for 2 years. You can generate it on the eBay developer page where you define your Application Login etc. Put the token as in your first post.

Otherwise, you have to go through the Auth Flow once. You will receive an additional "refresh token". You can than refresh the access token if it's not valid anymore.

Show me the whole code. Does it work with ebay api explorer? Did you managed to obtain the access token?

You have to replace categoryId=9355 with categoryId:9355 in aspect_filter like this:
https://api.ebay.com/buy/browse/v1/item_summary/search?category_ids=9355&limit=3&filter=sellers:{alba_mobil}&aspect_filter=categoryId:9355,Brand:{Apple},Model:{Apple iPhone 13 Pro}

await eBay.browse.search({
  "category_ids": "9355",
  "limit": 3,
  "filter": "sellers:{alba_mobil}",
  "aspect_filter": "categoryId:9355,Brand:{Apple},Model:{Apple iPhone 13 Pro}"
})

Can you try with encoded aspect_filter?
https://api.ebay.com/buy/browse/v1/item_summary/search?category_ids=139971&limit=3&filter=sellers:{saturn}&aspect_filter=categoryId%3A139971%2CBrand%3A%7BMicrosoft%7D%2CModel%3A%7BMicrosoft%20Xbox%20Series%20X%7D

Maybe you should ask in eBay Developer Forum...