| Total Complexity | 1 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from rest_framework import generics, permissions |
||
| 9 | class ProviderAuthView(generics.CreateAPIView): |
||
| 10 | permission_classes = [permissions.AllowAny] |
||
| 11 | serializer_class = ProviderAuthSerializer |
||
| 12 | |||
| 13 | def get(self, request, *args, **kwargs): |
||
| 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 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.