Authenticate with portal to get list of cards

master
Tanner Collin 4 years ago
parent cbb5a360b9
commit 9de94414d0
  1. 1
      .gitignore
  2. 6
      main.py
  3. 3
      secrets.py.example

1
.gitignore vendored

@ -103,3 +103,4 @@ ENV/
*.swo
card_data.json
secrets.py

@ -13,6 +13,8 @@ import serial
import time
from signal import *
import secrets
DEBUG = os.environ.get('DEBUG', False)
RELAY_PIN = 17
@ -127,11 +129,13 @@ def update_thread(card_data_queue):
logging.info('Cards changed, pulling update from API')
try:
res = requests.get(API_DOOR, timeout=5)
headers = {'Authorization': 'Bearer ' + secrets.DOOR_API_KEY}
res = requests.get(API_DOOR, headers=headers, timeout=5)
res.raise_for_status()
res = res.json()
except BaseException as e:
logging.error('Problem GETting door: {} - {}'.format(e.__class__.__name__, str(e)))
last_card_change = None
continue
logging.info('Got {} cards from API'.format(str(len(res))))

@ -0,0 +1,3 @@
# Door cards API key
# should be equal to the auth token value set in Spaceport
DOOR_API_KEY = ''
Loading…
Cancel
Save