Skip to content

Commit

Permalink
Fix token rotation deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Sep 20, 2023
1 parent e7af2c8 commit 63dcaec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@ func (u *Users) Remove(username string) (User, error) {
return mutation.Result.User, err
}

func (u *Users) RotateUserApiTokenAndGet(userID string) (string, error) {
func (u *Users) RotateToken(userID string) (string, error) {
var mutation struct {
RotateUserApiTokenMutation struct {
RotateUserApiToken struct {
Token string
} `graphql:"rotateUserApiToken"`
} `graphql:"rotateUserApiTokenAndGet(input:{id:$id})"`
Token string `graphql:"rotateToken(input:{id:$id})"`
}

variables := map[string]interface{}{
Expand All @@ -122,7 +118,7 @@ func (u *Users) RotateUserApiTokenAndGet(userID string) (string, error) {
return "", err
}

return mutation.RotateUserApiTokenMutation.RotateUserApiToken.Token, nil
return mutation.Token, nil
}

func userChangesetToVars(username string, changeset UserChangeSet) map[string]interface{} {
Expand Down
2 changes: 1 addition & 1 deletion cmd/humioctl/users_rotate_api_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func newUsersRotateApiTokenCmd() *cobra.Command {
userID := args[0]

client := NewApiClient(cmd)
newToken, apiErr := client.Users().RotateUserApiTokenAndGet(userID)
newToken, apiErr := client.Users().RotateToken(userID)
exitOnError(cmd, apiErr, "Error updating user")

cmd.Printf("New API Token: %s\n", newToken)
Expand Down

0 comments on commit 63dcaec

Please sign in to comment.