Passed
Pull Request — master (#244)
by Piotr
01:02
created

ProviderAuthView   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 13 1
1
from rest_framework import generics, permissions
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Unable to import 'rest_framework'
Loading history...
2
from rest_framework.response import Response
0 ignored issues
show
introduced by
Unable to import 'rest_framework.response'
Loading history...
3
4
from social_django.utils import load_backend, load_strategy
0 ignored issues
show
introduced by
Unable to import 'social_django.utils'
Loading history...
5
6
from djoser.social.serializers import ProviderAuthSerializer
7
8
9
class ProviderAuthView(generics.CreateAPIView):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
10
    permission_classes = [permissions.AllowAny]
11
    serializer_class = ProviderAuthSerializer
12
13
    def get(self, request, *args, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument args seems to be unused.
Loading history...
Unused Code introduced by
The argument kwargs seems to be unused.
Loading history...
14
        redirect_uri = request.GET.get('redirect_uri') or 'http://localhost/'
15
        strategy = load_strategy(request)
16
        strategy.session_set('redirect_uri', redirect_uri)
17
18
        backend_name = self.kwargs['provider']
19
        backend = load_backend(
20
            strategy, backend_name, redirect_uri=redirect_uri
21
22
        )
23
        authorization_url = backend.auth_url()
24
        return Response(data={
25
            'authorization_url': authorization_url,
26
        })
27