MCPcopy Index your code
hub / github.com/blacklanternsecurity/bbot / require_api_key

Method require_api_key

bbot/modules/base.py:314–340  ·  view source on GitHub ↗

Asynchronously checks if an API key is required and valid. Args: None Returns: bool or tuple: Returns True if API key is valid and ready. Returns a tuple (None, "error message") otherwise. Notes: - Fetc

(self)

Source from the content-addressed store, hash-verified

312 return
313
314 async def require_api_key(self):
315 """
316 Asynchronously checks if an API key is required and valid.
317
318 Args:
319 None
320
321 Returns:
322 bool or tuple: Returns True if API key is valid and ready.
323 Returns a tuple (None, "error message") otherwise.
324
325 Notes:
326 - Fetches the API key from the configuration.
327 - Calls the 'ping()' method to test API accessibility.
328 - Sets the API key readiness status accordingly.
329 """
330 self.api_key = self.config.get("api_key", "")
331 if self.auth_secret:
332 try:
333 await self.ping()
334 self.hugesuccess("API is ready")
335 return True, ""
336 except Exception as e:
337 self.trace(traceback.format_exc())
338 return None, f"Error with API ({str(e).strip()})"
339 else:
340 return None, "No API key set"
341
342 @property
343 def api_key(self):

Callers 6

setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80

Calls 4

pingMethod · 0.95
hugesuccessMethod · 0.95
traceMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected