Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 06fbc18

Browse files
author
Samuel Hassine
committed
[client] Pass the token when sending message
1 parent e3718a1 commit 06fbc18

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pycti/api/opencti_api_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(self, url, token, log_level="info", ssl_verify=False):
7171
logging.basicConfig(level=numeric_level)
7272

7373
# Define API
74+
self.api_token = token
7475
self.api_url = url + "/graphql"
7576
self.request_headers = {"Authorization": "Bearer " + token}
7677

@@ -110,6 +111,12 @@ def __init__(self, url, token, log_level="info", ssl_verify=False):
110111
"OpenCTI API is not reachable. Waiting for OpenCTI API to start or check your configuration..."
111112
)
112113

114+
def get_token(self):
115+
return self.api_token
116+
117+
def set_token(self, token):
118+
self.request_headers = {"Authorization": "Bearer " + token}
119+
113120
def query(self, query, variables={}):
114121
query_var = {}
115122
files_vars = []

pycti/connector/opencti_connector_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ def _send_bundle(self, channel, bundle, entities_types=None, update=False):
286286
"job_id": job_id,
287287
"entities_types": entities_types,
288288
"update": update,
289+
"token": self.opencti_token,
289290
"content": base64.b64encode(bundle.encode("utf-8")).decode("utf-8"),
290291
}
291292

0 commit comments

Comments
 (0)