Skip to content

Instantly share code, notes, and snippets.

@jjb
Last active February 11, 2017 11:38
Show Gist options
  • Save jjb/7621551 to your computer and use it in GitHub Desktop.
Save jjb/7621551 to your computer and use it in GitHub Desktop.
Leave closed Trello boards for which you are not an admin
  1. go here and get your Developer Key (ignore that token) https://trello.com/1/appKey/
  2. visit this url, with your Developer Key inserted as shown https://trello.com/1/authorize?key=YOURDEVELOPERKEY&name=My+Application&expiration=1day&response_type=token&scope=read,write
  3. grant access, and then get the token that is produced on the next page
  • You'll need to add a file in the same directory called settings.py that contains strings for MY_KEY, MY_TOKEN, and USER_TOKEN (USER_TOKEN can be an empty string)
  • Run the script with the last line commented out to see what boards you're leaving. When you're ready to do it for real, uncomment the last line.
from TrelloSimple.trelloSimple import TrelloSimple
from settings import MY_KEY, MY_TOKEN, USER_TOKEN
from sys import argv
import json
token = MY_TOKEN
if len(argv) > 1 and argv[1] == 'user':
token = USER_TOKEN
t = TrelloSimple(MY_KEY, token)
resp = t.get('members/me')
id_member = resp['id']
boards = t.get(['members','me','boards'],{'fields':'memberships,closed,name'})
for board in boards:
is_closed = board['closed']
is_admin = False
for member in board['memberships']:
if member['idMember'] == id_member and member['memberType'] == 'admin':
is_admin = True
if is_closed and not is_admin:
print "leave board %s: %s" % (board['id'], board['name'])
# uncomment this line when ready to delete boards
#t.delete(['boards',board['id'],'members',id_member])
MY_KEY=""
MY_TOKEN=""
USER_TOKEN=""
git clone https://developers.kilnhg.com/Code/Trello/Group/TrelloSimple.git
#...edit settings.py...
pip install requests
python script.py
@roboticsexpert
Copy link

why trello should not handle it in his ui ?

@rlueder
Copy link

rlueder commented Feb 8, 2017

If like me you're coming to this page looking for a way of leaving boards you are not the admin, Trello seems to have put together this: https://trello.com/support/leave-closed-board

@JoeNyland
Copy link

Thanks @rlueder that saved me some time! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment