Commit 3c58e75ffd2d365043eedf59cc3becb85610f5db

Authored by Zambom
1 parent ef85b948

Adding extra data to token response

Showing 1 changed file with 12 additions and 0 deletions   Show diff stats
api/views.py
... ... @@ -20,6 +20,7 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet):
20 20 queryset = User.objects.all()
21 21 permissions_classes = (IsAuthenticatedOrReadOnly,)
22 22  
  23 + @csrf_exempt
23 24 @detail_route(methods = ['post'])
24 25 def login(self, request):
25 26 username = request.DATA['email']
... ... @@ -60,6 +61,17 @@ def getToken(request):
60 61 auth = (oauth.client_id, oauth.client_secret)
61 62  
62 63 response = requests.post(request.build_absolute_uri(reverse('oauth2_provider:token')), data = data, auth = auth)
  64 +
  65 + json_r = json.loads(response.content.decode('utf-8'))
  66 +
  67 + json_r["message"] = ""
  68 + json_r["type"] = ""
  69 + json_r["title"] = ""
  70 + json_r["success"] = True
  71 + json_r["number"] = 1
  72 + json_r['extra'] = 0
  73 +
  74 + response = json.dumps(json_r)
63 75 except KeyError:
64 76 response = "Error"
65 77  
... ...