Skip to content

Commit 8928ac7

Browse files
committed
gracefully handling no api token
1 parent 814ed18 commit 8928ac7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

socketsecurity/socketcli.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,20 @@ def main_code():
4848
log.debug(f"config: {config.to_dict()}")
4949
output_handler = OutputHandler(config)
5050

51+
# Validate API token
52+
if not config.api_token:
53+
log.info("Socket API Token not found. Please set it using either:\n"
54+
"1. Command line: --api-token YOUR_TOKEN\n"
55+
"2. Environment variable: SOCKET_SECURITY_API_KEY")
56+
sys.exit(3)
57+
5158
sdk = socketdev(token=config.api_token)
5259
log.debug("sdk loaded")
5360

5461
if config.enable_debug:
5562
set_debug_mode(True)
5663
log.debug("Debug logging enabled")
5764

58-
# Validate API token
59-
if not config.api_token:
60-
log.info("Unable to find Socket API Token")
61-
sys.exit(3)
6265

6366
# Initialize Socket core components
6467
socket_config = SocketConfig(

0 commit comments

Comments
 (0)