How to delete/disable user through slack API?

后端 未结 3 740
一向
一向 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:15

    You can use Slack's SCIM API to enable and disable a user. Note that, as with the undocumented API endpoint mentioned in other answers this requires a Plus/Enterprise account.

    0 讨论(0)
  • 2021-01-13 19:33

    The users.profile.set apparently does not work for for setting each and every property of a user.

    To set the deleted property there is another API method called users.admin.setInactive. Its an undocumented method and it will only work on paid teams.

    0 讨论(0)
  • 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`
    
    0 讨论(0)
提交回复
热议问题