Teradata Package for Python Function Reference on VantageCloud Lake - set_auth_token - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
20.00.00.04
Published
March 2025
ft:locale
en-US
ft:lastEdition
2025-04-11
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
teradataml.scriptmgmt.lls_utils.set_auth_token = set_auth_token(base_url=None, client_id=None, pat_token=None, pem_file=None, **kwargs)
DESCRIPTION:
    Function to set the Authentication token to connect to User Environment Service
    in VantageCloud Lake.
    Note:
        User must have a privilege to login with a NULL password to use set_auth_token().
        Please refer to GRANT LOGON section in Teradata Documentation for more details.
        If ues_url and client_id are specified then authentication is through OAuth.
        If ues_url, pat_token, pem_file are specified then authentication is through PAT.
        Refresh token still works but only for OAuth authentication.
 
PARAMETERS:
 
    ues_url:
        Required Argument.
        Specifies the URL for User Environment Service in VantageCloud Lake.
        Types: str
 
    base_url:
        Required Argument.
        Specifies the CCP endpoint URL.
        Types: str
 
    client_id:
        Optional Argument.
        Specifies the id of the application that requests the access token from
        VantageCloud Lake.
        Types: str
 
    pat_token:
        Required, if PAT authentication is to be used, optional otherwise.
        Specifies the PAT token generated from VantageCloud Lake Console.
        Types: str
 
    pem_file:
        Required, if PAT authentication is to be used, optional otherwise.
        Specifies the path to private key file which is generated from VantageCloud Lake Console.
        Types: str
 
    **kwargs:
        username:
            Specifies the user for which authentication is to be requested.
            If not specified, then user associated with current connection is used.
            Note:
                1. Use this option only if name of the database username has lower case letters.
                2. This option is used only for PAT and not for OAuth.
            Types: str
 
        expiration_time:
            Specifies the expiration time of the token in seconds. After expiry time JWT token expires and
            UserEnv methods does not work, user should regenerate the token.
            Note:
                This option is used only for PAT and not for OAuth.
            Default Value: 31536000
            Types: int
 
        auth_token:
            Optional Parameter.
            Specifies the authentication token to connect to VantageCloud Lake.
            Notes:
                 * if "auth_token" is set through this function, then this function
                   should always be used only after create_context.
                 * use this option only if user has got JWT token and wants to set the same
                   instead of generating it again from this function.
            Types: str
 
RETURNS:
    True, if the operation is successful.
 
RAISES:
    TeradataMlException, RuntimeError.
 
EXAMPLES:
 
    # Example 1: Set the Authentication token using default client_id.
    >>> import getpass
    >>> set_auth_token(base_url=getpass.getpass("ues_url : "))
 
    # Example 2: Set the Authentication token by specifying the client_id.
    >>> set_auth_token(base_url=getpass.getpass("base_url : "),
    ...                client_id=getpass.getpass("client_id : "))
 
    # Example 3: Set the Authentication token by specifying the "pem_file" and "pat_token"
    #            without specifying "username".
    >>> import getpass
    >>> set_auth_token(base_url=getpass.getpass("base_url : "),
    ...                pat_token=getpass.getpass("pat_token : "),
    ...                pem_file=getpass.getpass("pem_file : "))
    True
 
    # Example 4: Set the Authentication token by specifying the "pem_file" and "pat_token"
    #            and "username".
    >>> import getpass
    >>> set_auth_token(base_url=getpass.getpass("base_url : "),
    ...                pat_token=getpass.getpass("pat_token : "),
    ...                pem_file=getpass.getpass("pem_file : "))
    ...                username = "alice")
    True