From 03a5fbf87fc07b9101983f7b93a886d1a4d9e302 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 26 Mar 2025 06:44:52 +0300 Subject: [PATCH] feat: ym api key --- marketplaces/yandexmarket.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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