diff options
-rwxr-xr-x | effitool | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -220,13 +220,25 @@ class Session: return sorted(obj.get('resources', [])) def get_client(self, client_id): - return self._api.get_json(self._token, '/clients/{}'.format(client_id)) + return self._api.get_json(self._token, self._get_client_path(client_id)) + + def update_client(self, client_id, client): + self._api.put_json(self._token, self._get_client_path(client_id), client) + + def _get_client_path(self, client_id): + return '/clients/{}'.format(client_id) def allow_scopes(self, client_id, scopes): - path = '/clients/{}'.format(client_id) - client = self._api.get_json(self._token, path) + client = self.get_client(client_id) client['allowed_scopes'] = uniq(client.get('allowed_scopes', []) + scopes) - self._api.put_json(self._token, path, client) + self.update_client(client_id, client) + + def deny_scopes(self, client_id, scopes): + client = self.get_client(client_id) + old_scopes = client.get('allowed_scopes', []) + client['allowed_scopes'] = uniq( + s for s in old_scopes if s not in denied_scopes) + self.update_client(client_id, client) def fetch_member(self, rid): headers = { |