Authenticate with portal to get list of cards
This commit is contained in:
parent
cbb5a360b9
commit
9de94414d0
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -103,3 +103,4 @@ ENV/
|
|||
*.swo
|
||||
|
||||
card_data.json
|
||||
secrets.py
|
||||
|
|
6
main.py
6
main.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))))
|
||||
|
|
3
secrets.py.example
Normal file
3
secrets.py.example
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Door cards API key
|
||||
# should be equal to the auth token value set in Spaceport
|
||||
DOOR_API_KEY = ''
|
Loading…
Reference in New Issue
Block a user