diff options
author | enahum <nahumhbl@gmail.com> | 2016-08-23 19:06:17 -0300 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-08-23 18:06:17 -0400 |
commit | 9ab5a7996247c98ed6267b638e1b313e7c4eb8ff (patch) | |
tree | 95579883cd48370ee48259b2bec02b124df2f200 /model | |
parent | e406a92fbbfe36765ab66d9879a9c94546c7c281 (diff) | |
download | chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.tar.gz chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.tar.bz2 chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.zip |
PLT-3745 - Deauthorize OAuth Apps (#3852)
* Deauthorize OAuth APIs
* Deautorize OAuth Apps Account Settings
* Fix typo in client method
* Fix issues found by PM
* Show help text only when there is at least one authorized app
Diffstat (limited to 'model')
-rw-r--r-- | model/client.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/model/client.go b/model/client.go index 2d154e49f..7ef35ef6f 100644 --- a/model/client.go +++ b/model/client.go @@ -1532,6 +1532,29 @@ func (c *Client) DeleteOAuthApp(id string) (*Result, *AppError) { } } +// GetOAuthAuthorizedApps returns the OAuth2 Apps authorized by the user. On success +// it returns a list of sanitized OAuth2 Authorized Apps by the user. +func (c *Client) GetOAuthAuthorizedApps() (*Result, *AppError) { + if r, err := c.DoApiGet("/oauth/authorized", "", ""); err != nil { + return nil, err + } else { + defer closeBody(r) + return &Result{r.Header.Get(HEADER_REQUEST_ID), + r.Header.Get(HEADER_ETAG_SERVER), OAuthAppListFromJson(r.Body)}, nil + } +} + +// OAuthDeauthorizeApp deauthorize a user an OAuth 2.0 app. On success +// it returns status OK or an AppError on fail. +func (c *Client) OAuthDeauthorizeApp(clientId string) *AppError { + if r, err := c.DoApiPost("/oauth/"+clientId+"/deauthorize", ""); err != nil { + return err + } else { + defer closeBody(r) + return nil + } +} + func (c *Client) GetAccessToken(data url.Values) (*Result, *AppError) { if r, err := c.DoPost("/oauth/access_token", data.Encode(), "application/x-www-form-urlencoded"); err != nil { return nil, err |