question

kl1k avatar image
0 Likes"
kl1k asked

Curl example for using oauth and Shopping API

Previously I was using curl to grab details of the items I am selling by using:


http://open.api.ebay.com/shopping?version=897&callname=GetSingleItem&appid='<my app id>'&siteid=3&responseencoding=JSON&IncludeSelector=Details&ItemID='<item ID>'


I now have to start using oauth and after reading all the links I'm still confused how to do this.


I've got a script to generate the oauth token and I believe I have to use pass this in a header X-EBAY-API-IAF-TOKEN


I've tried curl -H 'X-EBAY-API-IAF-TOKEN: <token>' <Above URL>

but keep getting "Application ID invalid" so this can't be right.


Is there someone who can provide a easy to follow curl example to do this. All the eBay links I've read don't seem to help.


Some links point to https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html

which say:


Set the following HTTP request headers:

  • Content-Type – Must be set to: application/x-www-form-urlencoded
  • Authorization – The word "Basic " followed by your Base64-encoded OAuth credentials (<client_id>:<client_secret>).




oauthshopping 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.

alvisinwales avatar image
0 Likes"
alvisinwales answered

This works:

C:\curl.exe -k "https://open.api.ebay.com/shopping?callname=GetSingleItem&siteid=3&version=963" -H "X-EBAY-API-IAF-TOKEN: v^1.1#AA==" -H "SOAPAction: none" -H "X-EBAY-API-VERSION: 963" -H "X-EBAY-API-REQUEST-ENCODING: SOAP" -i -d "@C:\XMLOUT_GETSINGLEITEM.txt"


The file contains:

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ebay:apis:eBLBaseComponents"><soapenv:Body><urn:GetSingleItemRequest><urn:Version>963</urn:Version><urn:MessageID>Soap call - OAuth Token in SHOPPING API</urn:MessageID><urn:ItemID>254449796763</urn:ItemID></urn:GetSingleItemRequest></soapenv:Body></soapenv:Envelope>

Make sure to use an Application Access 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.

kl1k avatar image
0 Likes"
kl1k answered

Thank you. That was easy :)

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.