This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Has anyone used SWQL or SQL to update a Bearer Token value for an API Poller?

We have a token that we renew on a regular basis.  When we have monthly patching and reboots of systems, the token is expiring during this process.  I created a .bat file that can generate a new token and I can parse it out to get the new token.  I would like to store it in the existing Bearer Token, or create a new one and update the token being used by the 5 other API Pollers that are using the same Bearer Token.  Any ideas on how to update this information with a script?

Parents
  • I've got this working within the api poller, and fully outside of the api poller, doing it both inside and outside an api poller sounds really hard. I know one way you could do it, but it comes with hefty limitations.

    This stuff's easier to chat about imo, feel free to drop a message

  • What is the proper format to pass in the properties? What are the specific key and values needed in the XML?

  • Are you referring to a SWIS verb or whatever query the bearer token is used for?

  • Orion.Credential UpdateCredentials (int id, Dictionary<string, string> properties)

    The SWIS verb. I cannot get the second paramater of the function to pass correctly without it throwing an error. I looked at Credential Management · solarwinds/OrionSDK Wiki · GitHub, for what keys it requires. When i formatted it like this as an xml doc first, it threw some sort of error for  not having an "add" function which made me think it indeed does want it as a dictionary. But everytime i tried pass a dictionary it told me it was the incorrect format.
    How am i supposed to pass the xml string in a dictionary format?

    If you got it working, can you show me an example format?

  • #Documentation: https://github.com/solarwinds/OrionSDK/wiki/Credential-Management
    
    # Connect to the SolarWinds server
    $hostname = ""
    $username = ""
    $password = ""
    $swis = Connect-Swis -Soap12 https://$hostname/swvm/services/InformationService -Username $username -Password $password -IgnoreSslErrors
    
    
    
    $bearer_token_credset = ""
    $bearer_token_desc = ""
    $bearer_token = ""
    
    $properties = [System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]]::new()
    $properties.Add("Name", $bearer_token_credset);
    $properties.Add("Description", $bearer_token_desc);
    $properties.Add("Token", $bearer_token);
    
    
    # Define the parameters for the UpdateCredential function
    $CredentialID = 201
    # Call the UpdateCredential function
    Invoke-SwisVerb $swis Orion.Credential UpdateCredentials @($CredentialID, $properties)
    


    This is the error I'm getting:

Reply
  • #Documentation: https://github.com/solarwinds/OrionSDK/wiki/Credential-Management
    
    # Connect to the SolarWinds server
    $hostname = ""
    $username = ""
    $password = ""
    $swis = Connect-Swis -Soap12 https://$hostname/swvm/services/InformationService -Username $username -Password $password -IgnoreSslErrors
    
    
    
    $bearer_token_credset = ""
    $bearer_token_desc = ""
    $bearer_token = ""
    
    $properties = [System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]]::new()
    $properties.Add("Name", $bearer_token_credset);
    $properties.Add("Description", $bearer_token_desc);
    $properties.Add("Token", $bearer_token);
    
    
    # Define the parameters for the UpdateCredential function
    $CredentialID = 201
    # Call the UpdateCredential function
    Invoke-SwisVerb $swis Orion.Credential UpdateCredentials @($CredentialID, $properties)
    


    This is the error I'm getting:

Children