forked from lacework/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_tokens.py
More file actions
30 lines (21 loc) · 829 Bytes
/
example_tokens.py
File metadata and controls
30 lines (21 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
"""
Example script showing how to use the LaceworkClient class.
"""
import logging
import os
import random
from dotenv import load_dotenv
from laceworksdk import LaceworkClient
logging.basicConfig(level=logging.DEBUG)
load_dotenv()
if __name__ == "__main__":
# Use enviroment variables to instantiate a LaceworkClient instance
lacework_client = LaceworkClient(api_key=os.getenv("LW_API_KEY"),
api_secret=os.getenv("LW_API_SECRET"),
account=os.getenv("LW_ACCOUNT"))
# Token API
# Get all enabled API tokens
enabled_api_tokens = lacework_client.tokens.get_enabled()
# Get specified API token
api_token = lacework_client.tokens.get_token(random.choice(enabled_api_tokens["data"])["ACCESS_TOKEN"])