Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit ec80752

Browse files
techknowlogicklafriks
authored andcommitted
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
1 parent b2308e3 commit ec80752

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gitea/user_app.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func BasicAuthEncode(user, pass string) string {
2020
// AccessToken represents a API access token.
2121
// swagger:response AccessToken
2222
type AccessToken struct {
23+
ID int64 `json:"id"`
2324
Name string `json:"name"`
2425
Sha1 string `json:"sha1"`
2526
}
@@ -54,3 +55,9 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio
5455
"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}},
5556
bytes.NewReader(body), t)
5657
}
58+
59+
// DeleteAccessToken delete token with key id
60+
func (c *Client) DeleteAccessToken(user string, keyID int64) error {
61+
_, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil)
62+
return err
63+
}

0 commit comments

Comments
 (0)