change API field

This commit is contained in:
KF7EEL 2021-04-22 15:21:13 -07:00
parent 7b2b33b2d9
commit 830799db2c
5 changed files with 13 additions and 8 deletions

View File

@ -176,6 +176,7 @@ def build_config(_config_file):
'ACCESS_SYSTEMS_FILE': config.get(section, 'ACCESS_SYSTEMS_FILE'),
'MY_API_NAME': config.get(section, 'MY_API_NAME'),
'DASHBOARD_URL': config.get(section, 'DASHBOARD_URL'),
'SERVER_NAME': config.get(section, 'SERVER_NAME'),
})

View File

@ -6,7 +6,8 @@ import json
msg_xfer = {
'mode':'msg_xfer',
'system_name':'ABC',
'system_shortcut':'ABC',
'server_name':'Test HBlink Network',
'response_url':'http://localhost:8093/api/',
'auth_type':'private',
'credentials': {
@ -41,7 +42,8 @@ print('-----------------------------------------')
app_request = {
'mode':'app',
'system_name':'ABC',
'system_shortcut':'ABC',
'server_name':'Test HBlink Network',
'response_url':'http://localhost:8093/api/',
'auth_token':'1234567899',
'data':{
@ -61,7 +63,7 @@ print('-----------------------------------------')
app_response = {
'mode':'app',
'system_name':'APP',
'app_name':'Test HBlink App',
'auth_token':'736a9ced7e7688c951490a7f8e1ebdd4',
'data':{
1:{'source_app':'app_name',
@ -88,7 +90,7 @@ print(json_object)
print('-----------------------------------------')
raw_msg_xfer = {
'mode':'raw',
'system_name':'ABC',
'system_shortcut':'ABC',
'response_url':'http://localhost:8093/api/',
'auth_type':'private',
'credentials': {

View File

@ -176,6 +176,7 @@ AUTHORIZED_TOKENS_FILE: /tmp/hblink_auth_tokens.txt
AUTHORIZED_USERS_FILE: /path/to/authorized_users.txt
ACCESS_SYSTEMS_FILE: /path/to/access_systems.txt
MY_API_NAME: ABC
SERVER_NAME: Test HBLink Network
# The following options are used for the dashboard. The dashboard is optional.

View File

@ -255,7 +255,8 @@ def send_app_request(url, message, source_id):
auth_token.close()
app_request = {
'mode':'app',
'system_name':CONFIG['GPS_DATA']['MY_API_NAME'],
'system_shortcut':CONFIG['GPS_DATA']['MY_API_NAME'],
'server_name':CONFIG['GPS_DATA']['SERVER_NAME'],
'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'] + '/api',
'auth_token':the_token,
'data':{
@ -275,7 +276,7 @@ def send_msg_xfer(url, user, password, message, source_id, dest_id):
url = url + '/msg_xfer'
msg_xfer = {
'mode':'msg_xfer',
'system_name':CONFIG['GPS_DATA']['MY_API_NAME'],
'system_shortcut':CONFIG['GPS_DATA']['MY_API_NAME'],
'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'],
'auth_type':'private',
'credentials': {

View File

@ -741,8 +741,8 @@ def api(api_mode=None):
# Handle authorization
if api_data['auth_type'] == 'private':
#Authenticate
if api_data['system_name'] in authorized_users:
if api_data['credentials']['user'] == authorized_users[api_data['system_name']]['user'] and api_data['credentials']['password'] == authorized_users[api_data['system_name']]['password']:
if api_data['system_shortcut'] in authorized_users:
if api_data['credentials']['user'] == authorized_users[api_data['system_shortcut']]['user'] and api_data['credentials']['password'] == authorized_users[api_data['system_shortcut']]['password']:
print(api_data['credentials']['user'])
print(api_data['credentials']['password'])
for sms in api_data['data'].items():