https://github.com/chelnak/onetimesecret-go
A Go implementation of the onetimesecret.com api 🔒️
https://github.com/chelnak/onetimesecret-go
go-library golang secrets security
Last synced: over 1 year ago
JSON representation
A Go implementation of the onetimesecret.com api 🔒️
- Host: GitHub
- URL: https://github.com/chelnak/onetimesecret-go
- Owner: chelnak
- License: apache-2.0
- Created: 2021-08-20T18:14:47.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-15T12:18:47.000Z (almost 5 years ago)
- Last Synced: 2025-02-02T20:46:41.506Z (over 1 year ago)
- Topics: go-library, golang, secrets, security
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Api Client for onetimesecret.com
 [](https://goreportcard.com/report/github.com/chelnak/onetimesecret-go)
This is a Go implementation of the [onetimesecret.com api](https://onetimesecret.com/docs/api) api. The module aims to provide a developer friendly interface for all endpoints exposed by the api.
## Installation
```go
go get github.com/chelnak/onetimesecret-go
```
## Usage
```go
package main
import (
"context"
"fmt"
ots "github.com/chelnak/onetimesecret-go/onetimesecret"
)
func main() {
// Build a new client
client := ots.NewClient(
ots.WithUsername("otsuser@domain.com"),
ots.WithAPIKey("xxxxxxxx"),
)
// Send a request with context
ctx := context.Background()
response, err := client.GetStatus(ctx)
if err != nil {
panic(err)
}
fmt.Println(response.Status)
}
```
### Using a custom http.Client instance
```go
package main
import (
ots "github.com/chelnak/onetimesecret-go/onetimesecret"
"context"
)
func main() {
// Create a custom http client instance
customHttpClient := &http.Client{ ... }
// Build a new ots client and use WithHttpClient option
client := ots.NewClient(
ots.WithUsername("otsuser@domain.com"),
ots.WithApiKey("xxxxxxxx"),
ots.WithHttpClient(customHttpClient)
)
// Send a request with context
ctx := context.Background()
response, err := client.GetStatus(ctx)
if err != nil {
panic(err)
}
fmt.Println(response.Status)
}
```
> Note: By default, a default http.Client instance is used if one is not passed when creating a client instance.
More documentation can be found [here](https://pkg.go.dev/github.com/chelnak/onetimesecret-go).
## Unit testing
```go
go test -tags unit ./... -v
```
## Examples
```go
export OTS_USERNAME=otsuser@domain.com
export OTS_APIKEY=xxxxx
go test -tags example ./... -v
```
## Releasing
Releases are tag based. From the main branch do the following:
```go
git tag -a vX.X.X -m "Release vX.X.X some reason"
git push --follow-tags
```