I have a django backend for a mobile app.
Im using django rest framework, but im still writing my own views and logic because the api end points are not model based.
The request sent to me has a secret key in the headers which is associated to individual devices registered. Along with it it has post data consisting of device id and other details.
How do i access the secret key value from the header if i am writing my own custom views in django to check if the device id and the secret key passed, matches?
It's not different from a regular django view:
class MyAPIView(APIView):
def post(self, request, *args, **kwargs):
print self.request.META.get('HTTP_SECRET_KEY', None)
A standard Python dictionary containing all available HTTP headers. Available headers depend on the client and server...
https://docs.djangoproject.com/en/1.7/ref/request-response/#django.http.HttpRequest.META
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With