How to Set user_id for Backend API Calls in Superset #31891
Replies: 1 comment
-
I found a similar unsolved discussion that might be relevant to your question: Error applying base filter: 'user' when calling /api/v1/sqllab/execute API from backend to backend [1]. For setting the @contextmanager
def override_user(user: User | None, force: bool = True) -> Iterator[Any]:
if hasattr(g, "user"):
if force or g.user is None:
current = g.user
g.user = user
yield
g.user = current
else:
yield
else:
g.user = user
yield
delattr(g, "user") This function is tested in the Superset codebase to ensure it behaves correctly under different conditions [2][3]. This approach is more appropriate than manually setting To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
HI @waynewenswag
Hello Superset Community,
I am working on making API calls to Superset's /sqllab/execute endpoint from another backend service (not the frontend). I am able to trigger the call and process the query, but I need to ensure that the user_id is set correctly during the execution of the query.
My Question:
Is there a standard or recommended way to set the user_id when making backend-to-backend API calls to Superset? I am currently trying to set it manually via g.user, but I would like to know if there is a more appropriate or recommended method for this scenario in Superset.
Any guidance or suggestions on how to manage user context (like user_id) in such backend API calls would be greatly appreciated!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions