Jump to content
  • How to use the CredentialsService in Spotfire® using IronPython scripting


    This article describes how the CredentialsService can be used to store credentials for the current user. Set credentials are available until the user session ends - typically when the application or web browser is closed.

    These credentials are stored in-memory and available to use in the User Session in any subsequent scripts or other external API calls.

    Introduction

    This article describes how the CredentialsService can be used to store credentials for the current user. Set credentials are available until the user session ends - typically when the application or web browser is closed.

    These credentials are stored in-memory and available to use in the User Session in any subsequent scripts or other external API calls.

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Framework.ApplicationModel import CredentialsService
    from System.Threading import Thread 
    
    credService = Application.GetService(CredentialsService)
    
    # Store the username and map it with the key myuser
    credService.SetCredentials[str]('myuser',Thread.CurrentPrincipal.Identity.Name)
    
    # Get the currentuser
    if credService.HasCredentials("myuser"):
        currentuser=credService.TryGetCredentials[str]('myuser')
    
    # To Remove Credential key
    credService.RemoveCredentials("myuser")
    
    # Now this key can be accessed in any other python script using #credService.TryGetCredentials[str]('myuser') 
    # and does not need to be stored in a document property.
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...