G
G
Godwp2014-08-23 17:16:44
PHP
Godwp, 2014-08-23 17:16:44

YandexMarkertAPI: Problems with the token. How to fix?

I'm trying to connect a store to Ya.Market using the Yandex Market for Partner
library . I'm trying to do:

use Yandex\Market\MarketClient;
//
$market = new MarketClient(ACCESS_TOKEN);
$market->setClientId(CLIENT_ID);
//логин, указанный при регистрации в партнерском интерфейсе
$market->setLogin(MARKET_LOGIN);
$campaigns = $market->getCampaigns();
/** @var \Yandex\Market\Campaign $campaign */
foreach($campaigns as $campaign){
    print_r($campaign->toArray());
}

I am getting an error:
Fatal error: Uncaught exception 'Yandex\Common\Exception\ForbiddenException' with message 'Token is invalid' in phar:///home/yandex-php-library_master.phar/src/Yandex/Market/MarketClient.php:206

ACCESS_TOKEN - received in Settings -> Purchase API settings -> Authorization...
CLIENT_ID - in oauth.yandex.ru . I registered the application, Yandex.Market -> Yandex.Market API for partners
indicated its rights MARKET_LOGIN - your login on Yandex, as it is indicated here https://partner.market.yandex.ru/manage.xml . Type %login%@yandex.ru
In the purchase API settings
Authorization type - HEADER
Data format - JSON
Please tell me what I'm doing wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Godwp, 2014-08-24
@Godwp

When requesting Yandex, you need to authorize the application and receive a token from Yandex.
I got a debug token as it is written in the documentation and it all worked.
PS Before asking stupid questions on the toaster read the docs :c

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question