def yandex_metrika_callback_view(request):
    try:
        state = request.GET['state']
        code = request.GET['code']

        module = UserDashboardModule.objects.get(pk=state)

        client = YandexMetrikaClient()
        result, exception = client.oath_token_request(code)

        if result is None:
            messages.error(request, _('API request failed.'))
        else:
            module.update_settings(result)

        return redirect(reverse('jet-dashboard:update_module', kwargs={'pk': module.pk}))
    except KeyError:
        return HttpResponse(_('Bad arguments'))
    except UserDashboardModule.DoesNotExist:
        return HttpResponse(_('Module not found'))
def yandex_metrika_callback_view(request):
    try:
        state = request.GET['state']
        code = request.GET['code']

        module = UserDashboardModule.objects.get(pk=state)

        client = YandexMetrikaClient()
        result, exception = client.oath_token_request(code)

        if result is None:
            messages.error(request, _('API request failed.'))
        else:
            module.update_settings(result)

        return redirect(reverse('jet-dashboard:update_module', kwargs={'pk': module.pk}))
    except KeyError:
        return HttpResponse(_('Bad arguments'))
    except UserDashboardModule.DoesNotExist:
        return HttpResponse(_('Module not found'))
Beispiel #3
0
def yandex_metrika_grant_view(request, pk):
    client = YandexMetrikaClient()
    return redirect(client.get_oauth_authorize_url(pk))
def yandex_metrika_grant_view(request, pk):
    client = YandexMetrikaClient()
    return redirect(client.get_oauth_authorize_url(pk))