Accessing Secret Server programmatically - Curl

Root > Secret Server > API - Web Services
Curl is a command-line tool for transferring data with URL syntax.  The download wizard for the executable can be found here.

When using Secret Server's web services, it is important to keep a few items in mind:
  1. When using the http://your-secret-server-url/webservices/sswebservice.asmx web service, a call must be made to Authenticate first. The token returned by this method is required by all the other methods.
  2. When using the http://your-secret-server-url/winauthwebservices/sswinauthwebservice.asmx web service, the user making the call must be NTLM authenticated and must exist as an enabled user in Secret Server.
  3. Legacy methods should be used when available - for example, GetSecretLegacy instead of GetSecret - when using Curl with web services.

Using Curl with the first method:

  1. curl -v -H "Content-Type: application/x-www-form-urlencoded" -d "username={NAME}&password={PASSWORD}&organization=&domain=" --url "http://your-secret-server-url/webservices/sswebservice.asmx/Authenticate"

This returns the token in the form below:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <AuthenticateResult xmlns:xsi="" xmlns:
  3. xsd="" xmlns="">
  4.   <Errors />
  5.   <Token>{TOKEN}</Token>
  6. </AuthenticateResult>

  1. curl -v -H "Content-Type: application/x-www-form-urlencoded" -d "secretId={SECRET ID}&token={TOKEN}" --url "http://your-secret-server-url/webservices/sswebservice.asmx/GetSecretLegacy"

This returns the requested Secret in XML form similar to the following:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <GetSecretResult xmlns:xsi="" xmlns:xsd
  3. ="" xmlns="">
  4.   <Errors />
  5.   <Secret>
  6.     <Name>{SECRET NAME}</Name>
  7.     <Items>
  8.       <SecretItem>
  9.         <Value>ABCDEF</Value>
  10.         <Id>1</Id>
  11.         <FieldId>1</FieldId>
  12.         <FieldName>FullName</FieldName>
  13.         <IsFile>false</IsFile>
  14.         <IsNotes>false</IsNotes>
  15.         <IsPassword>false</IsPassword>
  16.         <FieldDisplayName>Full Name</FieldDisplayName>
  17.       </SecretItem>
  18.       {MORE SECRET ITEMS HERE...}
  19.     </Items>
  20.     <Id>1</Id>
  21.     <SecretTypeId>1</SecretTypeId>
  22.     <FolderId>1</FolderId>
  23.     <IsWebLauncher>false</IsWebLauncher>
  24.   </Secret>
  25. </GetSecretResult>
Using Curl with the second method (the credentials passed in must be a domain user that is enabled within Secret Server):
  1. curl --ntlm --url "http://your-secret-server-url/winauthwebservices/sswinauthwebservice.asmx/GetSecretLegacy?secretId={SECRET ID}" --user "{USER}:{PASSWORD}"
This returns the Secret in the same XML format displayed above.

Add Feedback