This commit is contained in:
Egor Matveev 2022-04-02 19:07:18 +03:00
parent e2ebcdbfaa
commit 80bb8a3dbd
2 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ class VKAddView(BaseView):
token = os.getenv("VK_SERVICE_TOKEN")
resp = get(f'https://api.vk.com/method/secure.checkToken?token={access_token}&access_token={token}&v=5.131').json()
print("Got response while adding user", resp)
if 'success' in resp and resp['success'] == 1:
if 'response' in resp and 'success' in resp['response'] and resp['response']['success'] == 1:
user_id = resp['user_id']
self.request.user.userinfo.vk_user_id = user_id
self.request.user.userinfo.save()

View File

@ -19,8 +19,8 @@ class VKAuthView(BaseView):
return
access_token = self.request.GET['access_token']
token = os.getenv("VK_SERVICE_TOKEN")
resp = get(f'https://api.vk.com/method/secure.checkToken?token={access_token}&access_token={token}').json()
if 'success' in resp and resp['success'] == 1:
resp = get(f'https://api.vk.com/method/secure.checkToken?token={access_token}&access_token={token}&v=5.131').json()
if 'response' in resp and 'success' in resp['response'] and resp['response']['success'] == 1:
user_id = resp['user_id']
try:
user = User.objects.get(userinfo__vk_user_id=user_id)