File size: 1,024 Bytes
d371308
487e3d4
d371308
 
 
 
 
 
 
39f3b28
ee986d5
 
d371308
 
487e3d4
ee986d5
d371308
 
 
ee986d5
487e3d4
d371308
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr # Still need this if type hinting gr.Request

def get_url_user_token(request: gr.Request):
    """
    This function is called when the Gradio app loads.
    It attempts to retrieve 'user_token' from the URL query parameters.
    """
    user_token_from_url = "user_token not found in URL" # Default message
    if request:
        retrieved_token = request.query_params.get("session_id")
        org_urn = request.query_params.get("org_urn")
        if retrieved_token and org_urn:
            user_token_from_url = retrieved_token
            print(f"Retrieved user_token from URL: {user_token_from_url}")
        else:
            print(f"user_token key was not found in the URL query parameters.token {user_token_from_url}, urn {org_urn}")
    else:
        print("Request object not available to get_url_user_token function.")
        user_token_from_url = "Could not access request object on load"
    return user_token_from_url, org_urn

# You could add other utility functions here in the future