How to delete/disable user through slack API?

后端 未结 3 765
一向
一向 2021-01-13 19:10

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 al

3条回答
  •  温柔的废话
    2021-01-13 19:42

    in python you can do the following:

    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`
    

提交回复
热议问题