Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @api_view(['GET'])
- @authentication_classes((BasicAuthentication,))
- @permission_classes((IsAuthenticated,))
- def get_key(request):
- username = request.user.username
- enc = encode(key, username)
- return Response({'API_key': enc, 'username': username}, status=status.HTTP_200_OK)
- @api_view(['GET'])
- def get_data(request):
- user = request.user
- API_key = request.META.get('Authorization') # the value is null
- return Response({'API_key': API_key})
- headers = {'Authorization': 'yNd5vdL4f6d4f6dfsdF29DPh9vUtg=='}
- r = requests.get('http://localhost:8000/api/getdata', headers=headers)
- API_key = request.META.get('HTTP_AUTHORIZATION')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement