Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SM-1082: Add SM State to Go SDK Wrapper #559

Merged
merged 8 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions languages/go/bitwarden_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
dani-garcia marked this conversation as resolved.
Show resolved Hide resolved
req := AccessTokenLoginRequest{AccessToken: accessToken, StateFile: statePath}
command := Command{AccessTokenLogin: &req}

responseStr, err := c.commandRunner.RunCommand(command)
Expand Down
6 changes: 5 additions & 1 deletion languages/go/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is more descriptive.

Suggested change
// Configuring the statePath is optional, pass nil
// in AccessTokenLogin() to not use state
// Optional state file to persist access tokens between runs.

statePath := os.Getenv("STATE_PATH")

if projectName == "" {
projectName = "NewTestProject" // default value
}

err := bitwardenClient.AccessTokenLogin(accessToken)
err := bitwardenClient.AccessTokenLogin(accessToken, &statePath)
Thomas-Avery marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
panic(err)
}
Expand Down
Loading