diff --git a/marketplaces/yandexmarket.py b/marketplaces/yandexmarket.py index 72e568d..83ff969 100644 --- a/marketplaces/yandexmarket.py +++ b/marketplaces/yandexmarket.py @@ -20,13 +20,18 @@ class YandexmarketMarketplaceApi(BaseMarketplaceApi): logging.error(f"Couldn't load auth data for marketplace [{self.marketplace.id}]") self.is_valid = False return - access_token = auth_data.get('accessToken') - - self.limiter_key = str(marketplace.company_id) + str(access_token) + str(self.marketplace.campaign_id) - - self.headers = { - 'Authorization': f'OAuth oauth_token="{access_token}", oauth_client_id="{YANDEX_CLIENT_ID}"' - } + api_key = auth_data.get('apiKey') + if api_key: + self.limiter_key = str(marketplace.company_id) + str(api_key) + str(self.marketplace.campaign_id) + self.headers = { + 'Api-Key': api_key + } + else: + access_token = auth_data.get('accessToken') + self.limiter_key = str(marketplace.company_id) + str(access_token) + str(self.marketplace.campaign_id) + self.headers = { + 'Authorization': f'OAuth oauth_token="{access_token}", oauth_client_id="{YANDEX_CLIENT_ID}"' + } def get_headers(self): return self.headers