Replace VK OAuth with manual community token entry
Resolves #4 — VK OAuth flow caused "Security Error" because market sync requires a community access token, not a personal user token. Replaced OAuth with manual token input (same pattern as Evotor). Added step-by-step instructions. Updated health checker to validate community tokens via groups.getById instead of users.get. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,12 +7,10 @@
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger mt-4">
|
||||
{% if error == "invalid_state" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Ошибка безопасности. Попробуйте подключить аккаунт заново.
|
||||
{% elif error == "token_exchange" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Не удалось получить токен доступа от ВКонтакте. Попробуйте позже.
|
||||
{% elif error == "no_token" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>ВКонтакте не вернул токен доступа. Попробуйте позже.
|
||||
{% if error == "invalid_token" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Токен недействителен. Убедитесь, что скопировали ключ доступа сообщества правильно.
|
||||
{% elif error == "empty_token" %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Введите ключ доступа.
|
||||
{% else %}
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>Произошла ошибка при подключении: {{ error }}
|
||||
{% endif %}
|
||||
@@ -31,15 +29,15 @@
|
||||
<span class="text-muted small">Статус</span>
|
||||
<span class="badge bg-success"><i class="bi bi-check-circle me-1"></i>Подключено</span>
|
||||
</li>
|
||||
{% if connection.first_name or connection.last_name %}
|
||||
{% if connection.first_name %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span class="text-muted small">Профиль</span>
|
||||
<span>{{ connection.first_name }} {{ connection.last_name }}</span>
|
||||
<span class="text-muted small">Сообщество</span>
|
||||
<span>{{ connection.first_name }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if connection.vk_user_id %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span class="text-muted small">ID пользователя</span>
|
||||
<span class="text-muted small">ID сообщества</span>
|
||||
<span class="font-monospace small text-muted">{{ connection.vk_user_id }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -48,10 +46,18 @@
|
||||
<span class="small">{{ connection.connected_at.strftime("%d.%m.%Y %H:%M") }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-body d-grid gap-2">
|
||||
<a href="/vk/connect" class="btn btn-primary">Переподключить</a>
|
||||
<div class="card-footer">
|
||||
<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>
|
||||
<button type="submit" class="btn btn-outline-secondary">Обновить</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-body d-grid">
|
||||
<form method="post" action="/vk/disconnect">
|
||||
<button type="submit" class="btn btn-outline-danger w-100">Отключить аккаунт ВКонтакте</button>
|
||||
<button type="submit" class="btn btn-outline-danger w-100">Отключить ВКонтакте</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -59,17 +65,26 @@
|
||||
{# ── NOT CONNECTED STATE ── #}
|
||||
<div class="card-body">
|
||||
<p class="text-muted mb-3">
|
||||
Подключите ваш аккаунт ВКонтакте, чтобы система могла автоматически синхронизировать
|
||||
каталог товаров из Эвотор в вашу группу ВКонтакте.
|
||||
Для подключения вам нужен <strong>ключ доступа сообщества</strong> ВКонтакте.
|
||||
Синхронизация товаров работает только через сообщество.
|
||||
</p>
|
||||
<ul class="text-muted small mb-4">
|
||||
<li>Вы будете перенаправлены на сайт ВКонтакте для авторизации</li>
|
||||
<li>После подтверждения доступа синхронизация будет настроена автоматически</li>
|
||||
<li>Вы можете отключить доступ в любой момент</li>
|
||||
</ul>
|
||||
<div class="d-grid">
|
||||
<a href="/vk/connect" class="btn btn-primary btn-lg">Подключить ВКонтакте</a>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary">Подключить</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user