diff --git a/languages/go/README.md b/languages/go/README.md index e57badf7e..cea02e282 100644 --- a/languages/go/README.md +++ b/languages/go/README.md @@ -36,10 +36,12 @@ bitwardenClient, _ := sdk.NewBitwardenClient(&apiURL, &identityURL) ### Login -To login using an access token: +To login using an access token. Define some `statePath` and pass it to use state, or pass `nil` instead to not use state. ```go -apiKeyLogin, err := bitwardenClient.AccessTokenLogin(accessToken) +statePath := os.Getenv("STATE_PATH") + +err := bitwardenClient.AccessTokenLogin(accessToken, &statePath) ``` --- diff --git a/languages/go/bitwarden_client.go b/languages/go/bitwarden_client.go index 5e1108ce1..bd236de71 100644 --- a/languages/go/bitwarden_client.go +++ b/languages/go/bitwarden_client.go @@ -45,8 +45,8 @@ func NewBitwardenClient(apiURL *string, identityURL *string) (*BitwardenClient, }, nil } -func (c *BitwardenClient) AccessTokenLogin(accessToken string) error { - req := AccessTokenLoginRequest{AccessToken: accessToken} +func (c *BitwardenClient) AccessTokenLogin(accessToken string, statePath *string) error { + req := AccessTokenLoginRequest{AccessToken: accessToken, StateFile: statePath} command := Command{AccessTokenLogin: &req} responseStr, err := c.commandRunner.RunCommand(command) diff --git a/languages/go/example/example.go b/languages/go/example/example.go index 154c14618..deb353565 100644 --- a/languages/go/example/example.go +++ b/languages/go/example/example.go @@ -19,11 +19,15 @@ func main() { organizationIDStr := os.Getenv("ORGANIZATION_ID") projectName := os.Getenv("PROJECT_NAME") + // Configuring the statePath is optional, pass nil + // in AccessTokenLogin() to not use state + statePath := os.Getenv("STATE_PATH") + if projectName == "" { projectName = "NewTestProject" // default value } - err := bitwardenClient.AccessTokenLogin(accessToken) + err := bitwardenClient.AccessTokenLogin(accessToken, &statePath) if err != nil { panic(err) }