I'm trying to make a sandbox search call with the buy api. I created the App ID, Dev ID and Cert ID. I also have an ru name for sandbox and production. Then under "Get a Token from eBay via Your Application" page I speciefid an auth accept URL which is pointing to my applications php page. After log in to my sandbox user its redirecting me to my app url with some GET parameters. An "code" parameter and "expires_in" parameter (value: 299). I was expecting the code parameter is the token I need to use for the header when making calls, put I get the following error:
{ "errors" : [ { "errorId" : 1001, "domain" : "OAuth", "category" : "REQUEST", "message" : "Invalid access token", "longMessage" : "Invalid access token. Check the value of the Authorization HTTP request header." } ] }1
When I Generate an OAuth code at the ebay developer page under "Get a User Token Here" and use this one instead the request is working. The Generated code at the ebay page is also much longer compared to the one I get after Authentification as GET parameter.
My code:
$token_code = $_GET['code']; $url = "https://api.sandbox.ebay.com/buy/browse/v1/item_summary/search?q=drone&limit=3"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, array( "Authorization: Bearer $token_code" )); $response = curl_exec($curl); echo $response;
What I'm doing wrong here and how to get a working token after OAuth?
Best regards