From 71f569567152747daecc36c01f1aeb984bcb4d0f Mon Sep 17 00:00:00 2001 From: Alan Mitchell Date: Thu, 11 Jul 2019 10:05:28 -0800 Subject: [PATCH] Changed location and processing of Store Key for Things Network data. --- bmsapp/views.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bmsapp/views.py b/bmsapp/views.py index 2da5c79..26ad7c1 100644 --- a/bmsapp/views.py +++ b/bmsapp/views.py @@ -248,8 +248,8 @@ def store_readings_things(request): ''' Stores a set of sensor readings from the Things Network in the sensor reading database. The readings are assumed to originate from an HTTP Integration on an - Application in the Things Network. The Authorization header in the request contains - the BMON Store Key. The readings and other data are in the POST data encoded in JSON. + Application in the Things Network. The BMON Store Key is in a custom HTTP header. + The readings and other data are in the POST data encoded in JSON. ''' try: @@ -261,12 +261,9 @@ def store_readings_things(request): if 'payload_fields' not in req_data: return HttpResponse('No Data') - # See if the store key is valid. The Authorization header is of the format: - # BMON - try: - _, storeKey = request.META['HTTP_AUTHORIZATION'].split() - except: - storeKey = 'None_Present' + # See if the store key is valid. It's stored in the "store-key" header, which + # is found in the "HTTP_STORE_KEY" key in the META dictionary. + storeKey = request.META.get('HTTP_STORE_KEY', 'None_Present') if store_key_is_valid(storeKey): readings = [] -- 2.26.2