Hi, I'm using the Shopping API and GetSingleItem to retrieve the TextDescription, Details, ItemSpecifics and ShippingCosts from individual listings and I'm not even sure if I need to specify scopes for these requests.
My implementation works great by sending the APP-ID but now that I am required to upgrade to OAuth verification I don't know where to begin.
I spent a week+ reading all the documentation starting here: https://developer.ebay.com/api-docs/static/ebay-rest-landing.html
including reading about using OAuth to access eBay API's and client credentials grant flow, but it all looks more like theory than actual implementation steps or code samples I could easily implement and I really don't know where to begin.
My questions are:
1.) Referencing this page (https://developer.ebay.com/api-docs/static/oauth-tokens.html)
It says under the heading "Minting access tokens" that "The eBay token service generates, or mints, access tokens via two different grant flows:", then further down under the heading: "The eBay OAuth client libraries" it says: "eBay offers several client libraries that you can use to quickly implement the minting of OAuth tokens in your applications:" which leaves me wondering if the eBay token service generates the access tokens, or if I have to use one of the libraries provided.
2.) Using the PHP code sample provided below, I'm hoping someone could modify this code whereas it will generate the necessary token (Without use of additional libraries) which I could use in my GetSingleItem script to populate my X-EBAY-API-IAF-TOKEN header paramater like so: X-EBAY-API-IAF-TOKEN: getOAuthCreds. (getOAuthCreds being the name of the function below)
3.) If I have to use a library, could someone please suggest which library to use to be able to serve content to all devices as I currently do (And how to install it)?
Basically, I'm serving public knowledge content derived from a GetSingleItem call by passing my APP-ID in the header and am now being forced to upgrade to OAUth which I know nothing about even after studying and struggling with for a week and I still dont know where to begin as far as modifying my code to be able to continue serving this content after July 1st.
Any help is greatly appreciated.
The aforementioned function I created loosely based off of GetSingleItem call code is below:
function getOAuthCreds() { $endpoint = 'https://api.ebay.com/identity/v1/oauth2/token'; $request = "grant_type=client_credentials"; $request .= "scope=<scopeList>"; //I dont know how to URL encode this string of space-separated scopes to retrieve the TextDescription, Details, ItemSpecifics and ShippingCosts from individual listings $session = curl_init($endpoint); curl_setopt($session, CURLOPT_POST, true); curl_setopt($session, CURLOPT_POSTFIELDS, $request); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $headers = [ "X-EBAY-API-REQUEST-ENCODING: XML", //Not sure if I need this line 'Content-Type: application/x-www-form-urlencoded; charset=utf-8', 'Authorization = Basic <B64-encoded_oauth_credentials>' // I dont know how to provide this ]; curl_setopt($session, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($session); curl_close($session); return $response; }