From ec80752c9512cf07fc62ddc42565118183743942 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 20 Jun 2018 05:04:31 -0400 Subject: [PATCH] add ID as an output for token API and Delete token (#110) * add ID as an output for token API * add ability to delete token via SDK --- gitea/user_app.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gitea/user_app.go b/gitea/user_app.go index 08e9851..d3bfce9 100644 --- a/gitea/user_app.go +++ b/gitea/user_app.go @@ -20,6 +20,7 @@ func BasicAuthEncode(user, pass string) string { // AccessToken represents a API access token. // swagger:response AccessToken type AccessToken struct { + ID int64 `json:"id"` Name string `json:"name"` Sha1 string `json:"sha1"` } @@ -54,3 +55,9 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio "Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, bytes.NewReader(body), t) } + +// DeleteAccessToken delete token with key id +func (c *Client) DeleteAccessToken(user string, keyID int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil) + return err +}