Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. @api_view(['GET'])
  2. @authentication_classes((BasicAuthentication,))
  3. @permission_classes((IsAuthenticated,))
  4. def get_key(request):
  5. username = request.user.username
  6. enc = encode(key, username)
  7. return Response({'API_key': enc, 'username': username}, status=status.HTTP_200_OK)
  8.  
  9. @api_view(['GET'])
  10. def get_data(request):
  11. user = request.user
  12. API_key = request.META.get('Authorization') # the value is null
  13. return Response({'API_key': API_key})
  14.  
  15. headers = {'Authorization': 'yNd5vdL4f6d4f6dfsdF29DPh9vUtg=='}
  16. r = requests.get('http://localhost:8000/api/getdata', headers=headers)
  17.  
  18. API_key = request.META.get('HTTP_AUTHORIZATION')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement