Skip to content

Commit

Permalink
feat: Added revoke to keys
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedylandev committed Oct 31, 2024
1 parent cc03596 commit 99239f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ func RevokeKey(id string) error {
if err != nil {
return err
}
url := fmt.Sprintf("https://api.pinata.cloud/v3/files/groups/%s", id)
url := fmt.Sprintf("https://api.pinata.cloud/v3/pinata/keys/%s", id)

req, err := http.NewRequest("DELETE", url, nil)
req, err := http.NewRequest("PUT", url, nil)
if err != nil {
return errors.Join(err, errors.New("failed to create the request"))
}
Expand All @@ -196,7 +196,7 @@ func RevokeKey(id string) error {
return fmt.Errorf("server Returned an error %d, check CID", resp.StatusCode)
}

fmt.Println("Group Deleted")
fmt.Println("Key Revoked")

return nil

Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,20 @@ func main() {
return err
},
},
{
Name: "revoke",
Aliases: []string{"r"},
Usage: "Revoke an API key",
ArgsUsage: "[key]",
Action: func(ctx *cli.Context) error {
key := ctx.Args().First()
if key == "" {
return errors.New("No key provided")
}
err := RevokeKey(key)
return err
},
},
},
},
},
Expand Down

0 comments on commit 99239f7

Please sign in to comment.