Skip to content

Commit

Permalink
feat: pass api_access_token to executor client (#1473)
Browse files Browse the repository at this point in the history
* feat: pass api_access_token to executor client

* use execution metadata to store access token flag
  • Loading branch information
zhangvi7 authored Jul 8, 2024
1 parent 11caa51 commit 1092268
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion querybook/server/datasources/query_execution.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime

from flask import abort, Response, redirect
from flask import abort, Response, redirect, request
from flask_login import current_user

from app.flask_app import socketio
Expand Down Expand Up @@ -72,6 +72,10 @@ def create_query_execution(
query=query, engine_id=engine_id, uid=uid, session=session
)

metadata = metadata or {}
used_api_token = request.headers.get("api-access-token") is not None
if used_api_token:
metadata["used_api_token"] = used_api_token
if metadata:
logic.create_query_execution_metadata(
query_execution.id, metadata, session=session
Expand Down
12 changes: 12 additions & 0 deletions querybook/server/lib/query_executor/base_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,18 @@ def __init__(
self._client = None
self._cursor = None

query_execution_metadata = (
qe_logic.get_query_execution_metadata_by_execution_id(
self._query_execution_id
)
)
if query_execution_metadata:
self._used_api_token = query_execution_metadata.execution_metadata.get(
"used_api_token", False
)
else:
self._used_api_token = False

def __del__(self):
del self._logger
del self._cursor
Expand Down

0 comments on commit 1092268

Please sign in to comment.