Go SDK
Detailed Go SDK docs for Keeper Secrets Manager
Download and Installation
Install from GitHub
Find the latest Go SDK release at: https://github.com/Keeper-Security/secrets-manager-go
Source Code
Find the Go source code in the GitHub repository
Using the SDK
Initialize
In order to retrieve secrets, you must first initialize the secrets manager client.
Parameter
Type
Required
Default
Description
token
string
Yes
Keeper Secrets Manager One time token
hostName
string
Yes
Server to connect to
verifySslCerts
bool
yes
Choose whether to verify SSL certificates or not
config
IKeyValueStorage
yes
File Storage Configuration
The NewSecretsManager function will initialize Secrets Manager from provided parameters and store settings from ClientOptions struct.
Retrieve Secrets
Parameter
Type
Required
Default
Description
uids
[]string
Yes
Empty slice
Record UIDs to get
Response
Type: []*Record
Records with the specified UIDs, or all records shared with the Secrets Manager client if no UIDs are provided
Example Usage
Retrieve all Secrets
Retrieve Secrets with a Filter
Retrieve Secrets by Title
recordTitle
string
Yes
Record title to search for
Example Usage
Get Values From a Secret
Get a Password
Field types are based on the Keeper Record Type. For a detailed list of available fields based on the Keeper Record Type, see the record-type-info command in Keeper Commander.
Retrieve Values using Keeper Notation
Parameter
Type
Required
Default
Description
query
String
Yes
Keeper Notation query for getting a value from a specified field
Returns
Type: []interface{}
The value of the queried field
Retrieve TOTP Code
Parameter
Type
Required
Default
Description
url
string
Yes
TOTP Url
Update a Secret
Record update commands don't update local record data on success (esp. updated record revision) so any consecutive updates to an already updated record will fail due to revision mismatch. Make sure to reload all updated records after each update batch.
Update Password
Parameter
Type
Required
Default
Description
password
string
Yes
New password to set to the record
Update Other Fields
Parameter
Type
Required
Default
Description
field
string
Yes
name of the field to update
value
string
Yes
Value to set the field to
Update Secret in Vault
Save the record to make the changes made appear in the
Parameter
Type
Required
Default
Description
record
KeeperRecord
Yes
Record with updated field to save changes for
Example Usage
Update Password
Update other fields
Each record field type is represented by a class. Cast the field to the corresponding class in order to correctly access the field's value. Check the Record Types documentation for a list of field types.
Generate a Random Password
length
int
Yes
lowercase
int
Yes
uppercase
int
Yes
digits
int
Yes
specialCharacters
int
Yes
Each parameter indicates the minimum number of a type of character to include. For example, uppercase indicates the minimum uppercase letters to include.
Download a File
Parameter
Type
Required
Default
Description
title
string
Yes
Name of file to download
path
string
Yes
Path to save the file to
Response
Type: bool
Did the file save succeed
Example Usage
Upload a File
ownerRecord
Record
Yes
The record to attach the uploaded file to
file
KeeperFileUpload
Yes
The File to upload
name
string
Yes
What the name of the file will be in Keeper once uploaded
title
string
Yes
What the title of the file will be in Keeper once uploaded
type
string
Yes
The mime type of data in the file. 'application/octet-stream' for example
data
[]byte
Yes
File data as bytes
Example Usage
Create a Secret
Prerequisites:
Shared folder UID
Shared folder must be accessible by the Secrets Manager Application
You and the Secrets Manager application must have edit permission
There must be at least one record in the shared folder
Created records and record fields must be formatted correctly
See the documentation for expected field formats for each record type
TOTP fields accept only URL generated outside of the KSM SDK
After record creation, you can upload file attachments using UploadFile
recordUid
string
No
auto generated random UID
folderUid
string
Yes
record
*RecordCreate
Yes
createOptions
CreateOptions
Yes
recordData
*RecordCreate
Yes
folders
[]*KeeperFolder
No
This example creates a login type record with a login value and a generated password.
This example creates a record with a custom record type.
Delete a Secret
The Go KSM SDK can delete records in the Keeper Vault.
recordUids
[]string
Yes
Caching
To protect against losing access to your secrets when network access is lost, the Go SDK allows caching of secrets to the local machine in an encrypted file.
Setup and Configure Cache
In order to setup caching in the Go SDK, use the function SetCache(cache ICache) to set the cache to either one of the built-in memory or file based caches or use your own implementation.
The Go SDK includes a memory based cache and a file based cache for convenience.
Folders
Folders have full CRUD support - create, read, update and delete operations.
Read Folders
Downloads full folder hierarchy.
Response
Type: []*KeeperFolder, error
Example Usage
Create a Folder
Requires CreateOptions and folder name to be provided. The folder UID parameter in CreateOptions is required - UID of a shared folder, while sub-folder UID is optional and if missing new regular folder is created directly under the parent (shared folder). There's no requirement for the sub-folder to be a direct descendant of the parent shared folder - it could be many levels deep.
createOptions
CreateOptions
Yes
The parent and sub-folder UIDs
folderName
string
Yes
The Folder name
folders
[]*KeeperFolder
No
List of folders to use in the search for parent and sub-folder from CreateOptions
Example Usage
Update a Folder
Updates the folder metadata - currently folder name only.
folderUid
string
Yes
The folder UID
folderName
string
Yes
The new folder name
folders
[]*KeeperFolder
No
List of folders to use in the search for parent folder
Example Usage
Delete Folders
Removes a list of folders. Use forceDeletion flag to remove non-empty folders.
folderUids
[]string
Yes
The folder UID list
forceDeletion
bool
Yes
Force deletion of non-empty folders
Example Usage
Last updated
Was this helpful?

