The Akeyless Dev Hub

If you're looking for help with the only zero-trust, SaaS, unified platform for secrets management - you've come to the right place.

This is our documentation and updates center.

Documentation

Introduction

The Akeyless SDK for Go makes it easy for you to integrate your Go applications, libraries, or scripts with the Akeyless Vault secret management services.
The below Go code examples shows a typical sequence of how to integrate secrets into your application.

Installation

Use go get to retrieve the package in order to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/akeylesslabs/akeyless-proxy-api-golang

To update the package use go get -u to retrieve the latest version.

go get -u github.com/akeylesslabs/akeyless-proxy-api-golang

API Server Configuration

cfg := akl.NewConfiguration()
cfg.BasePath = "http://127.0.0.1:8080"
client := akl.NewAPIClient(cfg)
api := client.DefaultApi
ctx := context.Background()

Authentication

accessId := os.Getenv("AKEYLESS_ACCESS_ID")
    accessKey := os.Getenv("AKEYLESS_ACCESS_KEY")

    if accessId == "" || accessKey == "" {
        panic("Require Access ID and Access Key")
    }

    // Authenticate to the service and returns an access token
    authReplyObj, _,err := api.Auth(ctx, accessId, &akl.AuthOpts{
        AccessKey: optional.NewString(accessKey),
    })
    if err != nil {
        panic(err.Error())
    }

    token := authReplyObj.Token

📘

Authentication method

In addition to authentication with Access-ID and Access-Key, you can authenticate to Akeyless Vault with username and password.

Create a New Static Secret

secretName := "name_example"
secretValue := "value_example"

// Create new static secret
_, _,err = api.CreateSecret(ctx, secretName, secretValue, token, nil)
if err != nil {
    panic(err.Error())

Get Static Secret Value

getValReplyObj, _,err := api.GetSecretValue(ctx, secretName, token)

Get Static Secret Details

// Get static secret details
descReplyObj, _,err := api.DescribeItem(ctx, secretName, token)
if err != nil {
        panic(err.Error())
}

Update Static Secret Value

// Update static secret value
newSecretValue := "value_example"
_, _,err = api.UpdateSecretVal(ctx, secretName, newSecretValue, token, nil)
if err != nil {
    panic(err.Error())
}

📘

Documentation for API calls

https://github.com/akeylesslabs/akeyless-go-sdk

Updated 4 months ago

Go SDK


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.