Add VK OAuth implicit flow and fix sync issues
- Replace manual community token entry with OAuth button that redirects to VK authorization and auto-saves token via /vk/callback - Fix groups.get API call (was groups.getById) to correctly retrieve admin group id and name from user token response - Fix price comparison: VK price.amount is in roubles, not kopecks - Keep manual token input as fallback when VK_CLIENT_ID is not set Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,9 +8,11 @@
|
||||
{% if error %}
|
||||
<div class="alert alert-danger mt-4">
|
||||
{% if error == "invalid_token" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Токен недействителен. Убедитесь, что скопировали ключ доступа сообщества правильно.
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Токен недействителен или у него нет прав администратора сообщества.
|
||||
{% elif error == "empty_token" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Введите ключ доступа.
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Введите токен.
|
||||
{% elif error == "no_client_id" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Автоматическое подключение не настроено. Введите токен вручную.
|
||||
{% else %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Произошла ошибка при подключении: {{ error }}
|
||||
{% endif %}
|
||||
@@ -47,10 +49,10 @@
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-footer">
|
||||
<p class="text-muted small mb-2">Обновить ключ доступа:</p>
|
||||
<p class="text-muted small mb-2">Обновить токен пользователя:</p>
|
||||
<form method="post" action="/vk/token">
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" name="token" class="form-control font-monospace" placeholder="Новый ключ доступа" required>
|
||||
<input type="text" name="token" class="form-control font-monospace" placeholder="Новый токен пользователя" required>
|
||||
<button type="submit" class="btn btn-outline-secondary">Обновить</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -64,25 +66,31 @@
|
||||
{% else %}
|
||||
{# ── NOT CONNECTED STATE ── #}
|
||||
<div class="card-body">
|
||||
<p class="text-muted mb-3">
|
||||
Для подключения вам нужен <strong>ключ доступа сообщества</strong> ВКонтакте.
|
||||
Синхронизация товаров работает только через сообщество.
|
||||
{% if vk_client_id %}
|
||||
<p class="text-muted mb-4">
|
||||
Нажмите кнопку ниже, чтобы авторизоваться через ВКонтакте и выдать доступ к управлению товарами вашего сообщества.
|
||||
</p>
|
||||
|
||||
<ol class="text-muted small mb-4">
|
||||
<li class="mb-1">Откройте <a href="https://vk.com" target="_blank" rel="noopener">vk.com <i class="bi bi-box-arrow-up-right small"></i></a> и перейдите в управление вашим сообществом.</li>
|
||||
<li class="mb-1">Перейдите в раздел <strong>Настройки → Работа с API</strong>.</li>
|
||||
<li class="mb-1">Создайте ключ доступа с правами <strong>Управление товарами</strong> и <strong>Управление сообществом</strong>.</li>
|
||||
<li class="mb-1">Скопируйте ключ и вставьте его в поле ниже.</li>
|
||||
</ol>
|
||||
<div class="d-grid mb-3">
|
||||
<a href="/vk/connect" class="btn btn-primary btn-lg">
|
||||
<i class="bi bi-box-arrow-in-right me-2"></i>Подключить ВКонтакте
|
||||
</a>
|
||||
</div>
|
||||
<hr class="my-4">
|
||||
<p class="text-muted small mb-2">Или введите токен вручную:</p>
|
||||
{% else %}
|
||||
<p class="text-muted mb-3">
|
||||
Для синхронизации товаров необходим <strong>токен пользователя</strong> ВКонтакте
|
||||
с правами на управление товарами сообщества.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="/vk/token">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small text-muted">Ключ доступа сообщества</label>
|
||||
<input type="text" name="token" class="form-control font-monospace" placeholder="Вставьте ключ доступа" required autofocus>
|
||||
<label class="form-label small text-muted">Токен пользователя ВКонтакте</label>
|
||||
<input type="text" name="token" class="form-control font-monospace" placeholder="Вставьте токен пользователя" required {% if vk_client_id %}{% else %}autofocus{% endif %}>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary">Подключить</button>
|
||||
<button type="submit" class="btn {% if vk_client_id %}btn-outline-secondary{% else %}btn-primary{% endif %}">Подключить</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user