I’m using Sandbox Auth. Token here and it always sends me an error like this.
Error: Auth token is invalid. Validation of the authentication token in API request failed.
But if I use my Production Auth. Token it seems to workout and has no problem at all.
I’ve also checked the validity of my Sandbox Token and the expiration date is November 2016 which is far enough. Can someone please help me regarding my problem? Thanks in advance.
Here’s the code:
require __DIR__.'/../vendor/autoload.php';
$config = require __DIR__.'/../configuration.php';
use DTSeBaySDKConstants;
use DTSeBaySDKTradingServices;
use DTSeBaySDKTradingTypes;
use DTSeBaySDKTradingEnums;
$service = new ServicesTradingService(array(
'apiVersion' => $config['tradingApiVersion'],
'siteId' => ConstantsSiteIds::US
));
$request = new TypesGetMyeBaySellingRequestType();
$request->RequesterCredentials = new TypesCustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];
$request->ActiveList = new TypesItemListCustomizationType();
$request->ActiveList->Include = true;
$request->ActiveList->Pagination = new TypesPaginationType();
$request->ActiveList->Pagination->EntriesPerPage = 10;
$request->ActiveList->Sort = EnumsItemSortTypeCodeType::C_CURRENT_PRICE_DESCENDING;
$pageNum = 1;
do {
$request->ActiveList->Pagination->PageNumber = $pageNum;
$response = $service->getMyeBaySelling($request);
echo "==================nResults for page $pageNumn==================n";
if (isset($response->Errors)) {
foreach ($response->Errors as $error) {
printf("%s: %sn%snn",
$error->SeverityCode === EnumsSeverityCodeType::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 %.2fn",
$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
2
Answers
Base on what was given I can almost guarantee you are sending your request to
https://api.ebay.com/ws/api.dll (which is why production auth works)
instead of sending it to
https://api.sandbox.ebay.com/ws/api.dll (in which the sandox auth
SHOULD work)
Additional notes
Make sure all three of the developer id’s are sandbox compared to production because they do differ
Also it should be noted sandbox has a bunch more bugs than production, so personally I just use production to set up my calls and stuff.
By default the SDK will connect to the production API. If you want to use the sandbox API just pass true to the sandbox configuration option when creating your TradingService object. A list of all the configuration options is available.