telegraph/revoke_access_token.go

31 lines
862 B
Go
Raw Normal View History

2017-09-04 21:09:59 +00:00
package telegraph
import (
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
2018-07-27 11:51:14 +00:00
type revokeAccessTokenParameters struct {
// Access token of the Telegraph account.
AccessToken string `json:"access_token"` // required
}
// RevokeAccessToken revoke access_token and generate a new one, for example, if the user would
// like to reset all connected sessions, or you have reasons to believe the token was compromised. On
// success, returns an Account object with new access_token and auth_url fields.
2018-07-27 11:51:14 +00:00
func (a *Account) RevokeAccessToken() (r *Account, err error) {
args := http.AcquireArgs()
2018-07-27 11:51:14 +00:00
defer http.ReleaseArgs(args)
args.Add("access_token", a.AccessToken)
2017-09-04 21:09:59 +00:00
2018-07-27 11:51:14 +00:00
dst := new(Response)
dst, err = makeRequest("revokeAccessToken", args)
2017-09-04 21:09:59 +00:00
if err != nil {
2018-07-27 11:51:14 +00:00
return
2017-09-04 21:09:59 +00:00
}
2018-07-27 11:51:14 +00:00
r = new(Account)
err = json.Unmarshal(*dst.Result, r)
return
2017-09-04 21:09:59 +00:00
}