Ebay Auth Marker

I am using Sandbox Auth. The token is here and it always sends me such an error.

Error: Authentication token is invalid. Failed to validate the authentication token in the API request.

But if I use my Auth. The token seems to be exercising and having no issues at all.

I also checked the validity of my Sandbox token and the expiration date is November 2016 which is quite long. Can anyone help me in solving my problem? Thanks in advance.

Here's the code:

require __DIR__.'/../vendor/autoload.php';

$config = require __DIR__.'/../configuration.php';

use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Trading\Services;
use \DTS\eBaySDK\Trading\Types;
use \DTS\eBaySDK\Trading\Enums;

$service = new Services\TradingService(array(
    'apiVersion' => $config['tradingApiVersion'],
    'siteId' => Constants\SiteIds::US
));

$request = new Types\GetMyeBaySellingRequestType();

$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];

$request->ActiveList = new Types\ItemListCustomizationType();
$request->ActiveList->Include = true;
$request->ActiveList->Pagination = new Types\PaginationType();
$request->ActiveList->Pagination->EntriesPerPage = 10;
$request->ActiveList->Sort = Enums\ItemSortTypeCodeType::C_CURRENT_PRICE_DESCENDING;

$pageNum = 1;

do {
    $request->ActiveList->Pagination->PageNumber = $pageNum;
    $response = $service->getMyeBaySelling($request);

echo "==================\nResults for page $pageNum\n==================\n";

if (isset($response->Errors)) {
    foreach ($response->Errors as $error) {
        printf("%s: %s\n%s\n\n",
            $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning',
            $error->ShortMessage,
            $error->LongMessage
        );
    }
}

if ($response->Ack !== 'Failure' && isset($response->ActiveList)) {
    foreach ($response->ActiveList->ItemArray->Item as $item) {
        printf("(%s) %s: %s %.2f\n",
            $item->ItemID,
            $item->Title,
            $item->SellingStatus->CurrentPrice->currencyID,
            $item->SellingStatus->CurrentPrice->value
        );
    }
}

$pageNum += 1;

} while(isset($response->ActiveList) && $pageNum <= $response->ActiveList->PaginationResult->TotalNumberOfPages);

      

Credits to Sir David T. Sadler

+3


source to share


2 answers


By default, the SDK will connect to the production API. If you want to use the sandbox API, just pass true for the sandbox configuration parameter when creating the TradingService object. A list of all configuration parameters is available .



$service = new Services\TradingService(array(
    'apiVersion' => $config['tradingApiVersion'],
    'siteId' => Constants\SiteIds::US,
    'sandbox' => true
));

      

+4


source


Based on what was given, I almost guarantee that you are submitting your request to

https://api.ebay.com/ws/api.dll (this is why auth works)

instead of sending it to

https://api.sandbox.ebay.com/ws/api.dll (in which auth sandox MUST work)



Additional Notes

Make sure all three developer IDs are sandboxed versus production because they are different

It should also be noted that there are a bunch more bugs in the sandbox than production, so personally I just use production to customize my calls, etc.

+1


source







All Articles