[英]How to delete/disable user through slack API?
I have tried multiple approaches to this.我已经尝试了多种方法来解决这个问题。 Tried first getting the user without any user id - this returns me just my user, then tried getting user with other id's and it also retrieves data correctly.
首先尝试在没有任何用户 ID 的情况下获取用户 - 这仅返回我的用户,然后尝试获取具有其他 ID 的用户,并且它还正确检索数据。 However, I can't seem to be able to set user attribute 'deleted'.
但是,我似乎无法将用户属性设置为“已删除”。 i'm using this python approach.
我正在使用这种 python 方法。
slack_client.api_call('users.profile.set', deleted=True, user='U36D86MNK')
However I get the error message of:但是我收到以下错误消息:
{u'error': u'invalid_user', u'ok': False}
Maybe someone has already done this?也许有人已经这样做了? It says in documentation that it's a paid service mentioning this message under a user property:
它在文档中说,这是一项付费服务,在用户属性下提及此消息:
This argument may only be specified by team admins on paid teams.
此参数只能由付费团队的团队管理员指定。
But shouldn't it give me a 'paid service' response in that case then?但在这种情况下,它不应该给我一个“付费服务”的回应吗?
The users.profile.set
apparently does not work for for setting each and every property of a user. users.profile.set
显然不适用于设置用户的每个属性。
To set the deleted
property there is another API method called users.admin.setInactive
.要设置
deleted
属性,还有另一个名为users.admin.setInactive
API 方法。 Its an undocumented method and it will only work on paid teams.它是一种未记录的方法,仅适用于付费团队。
in python you can do the following:在python中,您可以执行以下操作:
import requests
def del_slack_user(user_id): # the user_id can be found under get_slack_users()
key = 'TOKEN KEY' #replace token key with your actual token key
payload = {'token': key, 'user': user_id}
response = requests.delete('https://slack.com/api/users.admin.setInactive', params=payload)
print(response.content)
def get_slack_users():
url = 'https://slack.com/api/users.list?token=ACCESSTOKEN&pretty=1'
response = requests.get(url=url)
response_data = response.json() # turns the query into a json object to search through`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.