from django.shortcuts import render
from django.http import HttpResponse
from . import models
import requests
import json
from social_core.backends.yandex import YandexOAuth2

# Create your views here.

def index(request):
    return HttpResponse("Hello world!")


def VKAuth(request):
    all_objects = models.VKAuth.objects.get(id=1)
    try:
        code = request.GET['code']
        token = requests.get(f"https://oauth.vk.com/access_token/?client_id={all_objects.vkUserId}&client_secret={all_objects.clientSecret}&redirect_uri=http://127.0.0.1:8001/tapp/VKAuth/&code={code}")
        all_objects.vkToken = token.json()['access_token']
        all_objects.save
        return render(request, 'tapp/VKAuth.html', {"all_objects": all_objects, "code": token.json()['access_token']})
    except:
        return render(request, 'tapp/VKAuth.html', {"all_objects": all_objects, "code": "Нет кода"})


def YandexDirectAuth(request):
    # all_objects = models.YandexDirect.objects.get(id=1)
    return render(request, 'tapp/YandexDirect.html', {"all_objects": YandexOAuth2})

d5548c51c72c427740f406e0485964ce314241ba
<mask token>


def VKAuth(request):
    all_objects = models.VKAuth.objects.get(id=1)
    try:
        code = request.GET['code']
        token = requests.get(
            f'https://oauth.vk.com/access_token/?client_id={all_objects.vkUserId}&client_secret={all_objects.clientSecret}&redirect_uri=http://127.0.0.1:8001/tapp/VKAuth/&code={code}'
            )
        all_objects.vkToken = token.json()['access_token']
        all_objects.save
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': token.json()['access_token']})
    except:
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': 'Нет кода'})


<mask token>

<mask token>


def VKAuth(request):
    all_objects = models.VKAuth.objects.get(id=1)
    try:
        code = request.GET['code']
        token = requests.get(
            f'https://oauth.vk.com/access_token/?client_id={all_objects.vkUserId}&client_secret={all_objects.clientSecret}&redirect_uri=http://127.0.0.1:8001/tapp/VKAuth/&code={code}'
            )
        all_objects.vkToken = token.json()['access_token']
        all_objects.save
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': token.json()['access_token']})
    except:
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': 'Нет кода'})


def YandexDirectAuth(request):
    return render(request, 'tapp/YandexDirect.html', {'all_objects':
        YandexOAuth2})

<mask token>


def index(request):
    return HttpResponse('Hello world!')


def VKAuth(request):
    all_objects = models.VKAuth.objects.get(id=1)
    try:
        code = request.GET['code']
        token = requests.get(
            f'https://oauth.vk.com/access_token/?client_id={all_objects.vkUserId}&client_secret={all_objects.clientSecret}&redirect_uri=http://127.0.0.1:8001/tapp/VKAuth/&code={code}'
            )
        all_objects.vkToken = token.json()['access_token']
        all_objects.save
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': token.json()['access_token']})
    except:
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': 'Нет кода'})


def YandexDirectAuth(request):
    return render(request, 'tapp/YandexDirect.html', {'all_objects':
        YandexOAuth2})

from django.shortcuts import render
from django.http import HttpResponse
from . import models
import requests
import json
from social_core.backends.yandex import YandexOAuth2


def index(request):
    return HttpResponse('Hello world!')


def VKAuth(request):
    all_objects = models.VKAuth.objects.get(id=1)
    try:
        code = request.GET['code']
        token = requests.get(
            f'https://oauth.vk.com/access_token/?client_id={all_objects.vkUserId}&client_secret={all_objects.clientSecret}&redirect_uri=http://127.0.0.1:8001/tapp/VKAuth/&code={code}'
            )
        all_objects.vkToken = token.json()['access_token']
        all_objects.save
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': token.json()['access_token']})
    except:
        return render(request, 'tapp/VKAuth.html', {'all_objects':
            all_objects, 'code': 'Нет кода'})


def YandexDirectAuth(request):
    return render(request, 'tapp/YandexDirect.html', {'all_objects':
        YandexOAuth2})

from django.shortcuts import render
from django.http import HttpResponse
from . import models
import requests
import json
from social_core.backends.yandex import YandexOAuth2

# Create your views here.

def index(request):
    return HttpResponse("Hello world!")


def VKAuth(request):
    all_objects = models.VKAuth.objects.get(id=1)
    try:
        code = request.GET['code']
        token = requests.get(f"https://oauth.vk.com/access_token/?client_id={all_objects.vkUserId}&client_secret={all_objects.clientSecret}&redirect_uri=http://127.0.0.1:8001/tapp/VKAuth/&code={code}")
        all_objects.vkToken = token.json()['access_token']
        all_objects.save
        return render(request, 'tapp/VKAuth.html', {"all_objects": all_objects, "code": token.json()['access_token']})
    except:
        return render(request, 'tapp/VKAuth.html', {"all_objects": all_objects, "code": "Нет кода"})


def YandexDirectAuth(request):
    # all_objects = models.YandexDirect.objects.get(id=1)
    return render(request, 'tapp/YandexDirect.html', {"all_objects": YandexOAuth2})
