question

nedeezle avatar image
0 Likes"
nedeezle asked

How do I authenticate? Receiving 401 Unauthorized

I'm trying to figure out how to use their API, and am trying to make a simple GET request on an item, but getting an "Invalid access token" response. Their documentation is terrible, but what I tried is to get a prod user token with Auth'n'Auth by signing into a prod eBay user account from the dev console. That gives me a "user token". Then I include that user token in my header and using the prod endpoint, but receiving the invalid access token response. Does anyone know what I'm doing wrong here? Below is my request.

GET https://api.ebay.com/sell/inventory/v1/inventory_item/303769339544
Content-Type: application/json
Authorization: Bearer <USER TOKEN>
X-EBAY-C-MARKETPLACE-ID:EBAY_US


authentication failedauthorization
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hiperlights_russia avatar image
0 Likes"
hiperlights_russia answered

"Prod user token ... from the dev console" sounds terrible.

Use prod + prod or dev + dev.

Token TTL is about an hour so you will need to get new one with refresh token.

Do you have refresh token?

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

nedeezle avatar image
0 Likes"
nedeezle answered

I am using prod + prod. But I'm using the user token provided when I choose the Auth'n'Auth option and log in to a eBay user account.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hiperlights_russia avatar image
0 Likes"
hiperlights_russia answered

AFAIK Auth'n'Auth is used for XML API ONLY. Sorry for not writing it before.

Use Oauth for JSON API.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sagar_developersupport avatar image
0 Likes"
sagar_developersupport answered

Hi @nedeezle,

Inventory API works with oauth token. And please pass SKU value in the request

(GET https://api.ebay.com/sell/inventory/v1/inventory_item/{ sku}) to retrieve the inventory item record.

Or you can use getInventoryItems call to retrieves all your inventory item records.

Ref: https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/getInventoryItem

Note: Listings created outside Inventory API will not be visible via Inventory APIs.
You can also use GetItem call of trading API to get the details of this item: 303769339544 by using your 'auth n auth' user token.

Ref: https://developer.ebay.com/devzone/xml/docs/reference/ebay/getitem.html#samplebasic

Best Regards,
eBay Developer Support

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.