From 830799db2cf8a2e0fac59983ac81ac0c866baee7 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Thu, 22 Apr 2021 15:21:13 -0700 Subject: [PATCH] change API field --- config.py | 1 + dev/json_templates.py | 10 ++++++---- full_bridge-SAMPLE.cfg | 1 + full_bridge.py | 5 +++-- scripts/dashboard/dashboard.py | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config.py b/config.py index 921945f..958294b 100755 --- a/config.py +++ b/config.py @@ -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'), }) diff --git a/dev/json_templates.py b/dev/json_templates.py index 2c23cb3..ffd49af 100644 --- a/dev/json_templates.py +++ b/dev/json_templates.py @@ -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': { diff --git a/full_bridge-SAMPLE.cfg b/full_bridge-SAMPLE.cfg index 686f66d..cdac205 100644 --- a/full_bridge-SAMPLE.cfg +++ b/full_bridge-SAMPLE.cfg @@ -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. diff --git a/full_bridge.py b/full_bridge.py index f09e471..304c804 100644 --- a/full_bridge.py +++ b/full_bridge.py @@ -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': { diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index e01f8fd..ebd8bff 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -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():