I create a standalone application for VKontakte, I need to implement OAuth authorization, but the problem is that when I click on the "Sign in" button, I redirect back to the same page. The problem seems to be that authorization data (cookies, headers or something else) is not saved. Code:
import vk import re import sys from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtWidgets import * from PyQt5 import QtWebEngine from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow app = QApplication(sys.argv) def authorize(token): print(token) def url_changed(url): new_url = url.toString() if re.match(r'^.+access_token.+$', new_url): token = re.match(r'.+access_token=(.+)\&.+', new_url).group(1) authorize(token) else: print(new_url, 'doesn\'t match') app_id = '6641802' link = "https://oauth.vk.com/authorize?" + \ f"client_id={app_id}&" + \ "display=page&" + \ "redirect_uri=https://oauth.vk.com/blank.html&" + \ "scope=messages&" + \ "response_type=token&" + \ "v=5.80" QtWebEngine.QtWebEngine.initialize() web = QWebEngineView() web.load(QUrl(link)) web.urlChanged.connect(url_changed) web.show() sys.exit(app.exec_()) I note that if you follow this link through a normal browser, everything works fine there.
Доступ к личным сообщениям Приложению будут доступны Ваши личные сообщения, а также возможность отправлять сообщения от Вашего имени.something syatno me give access to your application :) Checked through your application (5356487), which has no requirements - access_token pulled out - gil9red