def authorize(self): self.app.log.debug('Authorizing a Trello user.') # validate required config parameters if not self.app.config.get('trello', 'auth_key'): raise error.ConfigError( "Missing config parameter 'trello.auth_key'! " "Please run 'scrum-tools trello authorize' first! ") try: tl = TrelloApi(self.app.config.get('trello', 'auth_key')) url = tl.get_token_url('scrum-tools', expires='30days', write_access=True) cprint( os.linesep.join([ "Please follow the link below and update these entries in the [trello] section " "of your scrum-tools config: ", " auth_key = %s" % self.app.config.get('trello', 'auth_key'), " auth_token = %s" % '<generated_token>' ]), 'green') cprint("URL: %s" % url, 'green') except RuntimeError as e: raise e
def main(req: func.HttpRequest) -> func.HttpResponse: logging.info('Python HTTP trigger function processed a request.') try: try: logging.info("connecting to Trello API") trello = TrelloApi(SECRETS.TRELLO_API_KEY) SECRETS.reload_trello_token() trello.set_token(SECRETS.TRELLO_AUTH_TOKEN) ingredients = get_trello_check_list(trello) except HTTPError as e : token_url= trello.get_token_url('My App', expires='30days', write_access=True) logging.exception(e) return func.HttpResponse( f"Authentication error with Trello API. Please access to this url and update the configuration with the new token : \n {token_url}", status_code=401 ) keep_connection,note = get_checklist_from_keep() send_checklist_to_keep(ingredients,note) sync_keep(keep_connection) logging.info("success!") return func.HttpResponse( f"Succes ! The new ingredients added are the following : \n {ingredients}", status_code=200 ) except Exception as e: logging.exception(e) return func.HttpResponse( str(e), status_code=500 )
def on_post(self, req, resp, token): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) storage = ZODB.FileStorage.FileStorage('trees/' + token + '.fs') db = ZODB.DB(storage) connection = db.open() root = connection.root if hasattr(root, 'tree'): tree = root.tree else: resp.body = "Initialize first" connection.close() db.close() storage.close() return lst = list(btree.inorder(tree)) connection.close() db.close() storage.close() if len(lst) > 0: id_new = trello.boards.new_list('Le5vKw7H', token)['id'] for card in lst: trello.cards.new(card, id_new)
def on_get(self, req, resp, board): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) response=trello.boards.get_list(board) lists= {} for lst in response: lists[lst['id']]=lst['name'] resp.body = json.dumps(lists)
def main(): """ Grab Trello Token Url for a given key. """ args = parse_args() trello = TrelloApi(args.trello_key) return trello.get_token_url(args.prog_name, expires=args.expires, write_access=False)
def on_get(self, req, resp): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) response=trello.members.get_board('agusrumayor') boards= {} for board in response: boards[board['id']]=board['name'] resp.body = json.dumps(boards)
def on_get(self, req, resp, lst): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) response=trello.lists.get_card(lst) cards= [] for card in response: cards.append(card['name']) resp.body = json.dumps(cards)
def on_get(self, req, resp): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) response = trello.members.get_board('agusrumayor') boards = {} for board in response: boards[board['id']] = board['name'] resp.body = json.dumps(boards)
def on_get(self, req, resp, board): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) response = trello.boards.get_list(board) lists = {} for lst in response: lists[lst['id']] = lst['name'] resp.body = json.dumps(lists)
def on_get(self, req, resp, lst): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) response = trello.lists.get_card(lst) cards = [] for card in response: cards.append(card['name']) resp.body = json.dumps(cards)
def trello_init(): trello = TrelloApi(TRELLO_APP_KEY) try: trello.set_token(open('.token.txt').read().strip()) except IOError: token_url = trello.get_token_url('Trello ', expires='never', write_access=True) print "Enter following URL in your browser:", token_url token = raw_input("Enter token please:") open('.token.txt', 'w').write(token) trello.set_token(token) return trello
def init(cls, organization): trello = TrelloApi(TRELLO_APP_KEY) try: trello.set_token(open('.token.txt').read().strip()) logger.debug("Trello token loaded") except IOError: token_url = trello.get_token_url('Trello ', expires='never', write_access=True) print("Enter following URL in your browser:", token_url) token = raw_input("Enter token please:") open('.token.txt', 'w').write(token) trello.set_token(token) return cls(trello, organization)
def authorize(self): self.app.log.debug('Authorizing a Trello user.') # validate required config parameters if not self.app.config.get('trello', 'auth_key'): raise error.ConfigError("Missing config parameter 'trello.auth_key'! " "Please run 'scrum-tools trello authorize' first! ") try: tl = TrelloApi(self.app.config.get('trello', 'auth_key')) url = tl.get_token_url('scrum-tools', expires='30days', write_access=True) cprint(os.linesep.join(["Please follow the link below and update these entries in the [trello] section " "of your scrum-tools config: ", " auth_key = %s" % self.app.config.get('trello', 'auth_key'), " auth_token = %s" % '<generated_token>']), 'green') cprint("URL: %s" % url, 'green') except RuntimeError as e: raise e
def on_post(self, req, resp, token): trello = TrelloApi(trelloconfig.api_key, token=trelloconfig.token) trello_token = trello.get_token_url('My App', expires='30days', write_access=True) storage = ZODB.FileStorage.FileStorage('trees/'+token+'.fs') db = ZODB.DB(storage) connection = db.open() root = connection.root if hasattr(root, 'tree'): tree = root.tree else: resp.body = "Initialize first" connection.close() db.close() storage.close() return lst = list(btree.inorder(tree)) connection.close() db.close() storage.close() if len(lst)> 0: id_new = trello.boards.new_list('Le5vKw7H', token)['id'] for card in lst: trello.cards.new(card, id_new)
def get_trello_app_token(app_key): trello = TrelloApi(app_key) print( trello.get_token_url('Trello2Text', expires='never', write_access=True)) print("Now got to the url above and authorize the app")
default='true', help='when false, logs changes it would make but does not alter data') args = parser.parse_args() try: trello = TrelloApi(TRELLO_APP_KEY) except NameError: print 'No TRELLO_APP_KEY settings found, please generate via the following URL and place in local_settings.py:' print ' - https://trello.com/1/appKey/generate' sys.exit() try: trello.set_token(TRELLO_USER_TOKEN) except NameError: print 'No TRELLO_USER_TOKEN settings found, please generate via the following URL and place in local_settings.py:' print ' - ' + trello.get_token_url( 'resistance-calendar-etl', expires='1day', write_access=True) sys.exit() dry_run_prefix = '' if True == args.dry_run: dry_run_prefix = '[dry_run]' INDEX_NAME_FIELD = 0 INDEX_EMAIL_FIELD = 1 INDEX_LINK_FIELD = 2 ################################################################################ # Looks thtough the card content and suggests labels as a dict with name and # color based on string matches #
url = raw_input("Copy and paste the link the of your Trello board:\n" ) # user's project link json_extension = ".json" # json extension to render json data final_url = url + json_extension # combine 2 previous elements json_object = urllib2.urlopen(final_url) data = json.load(json_object) boardId = data["actions"][0]["data"]["board"][ "id"] # ID of the board we're working on print( "Copy and paste the following link in your web browser to get a new token." ) print( trello.get_token_url("Similar Label Detector", expires="30days", write_access=True)) # visit site to get 64-character token # token given by website auth_token = "744be46a0777522b10e26f42a819274dcbdc490bfc6d927960dc555d0fdb94b7" trello.set_token(auth_token) cards = Cards(app_key, auth_token) boards = Boards(app_key, auth_token) cardIds = [] # empty list where we will store card ID's label_names = [] # empty list where we will store unmodified label names label_names_lc = [] # empty list where we will store lowercase label names print( "\nList of cards, their respective ID's, and their respective label names:"
def init(ctx): if len(ctx.obj.config.items()) > 1: print('Cykle is already initialized.') exit(0) # get trello api key trello_apikey = raw_input('Trello API Key: ') # get trello token trello_api = TrelloApi(trello_apikey) token_url = trello_api.get_token_url('Cykle', expires='30days', write_access=True) webbrowser.open(token_url) trello_token = raw_input('Trello Token: ') # get trello organization trello_orgnization = raw_input('Trello Organization: ') # get trello board id trello_board_name = raw_input('Trello Board Name: ') trello_api = TrelloApi(trello_apikey, trello_token) # get all boards of the organization # if it is not a member of the organiztion, abort try: boards = trello_api.organizations.get_board(trello_orgnization) except requests.exceptions.HTTPError as e: if e.response.status_code == 401: print('Aborted. You MUST be member of the organization(%s).' % trello_orgnization) elif e.response.status_code == 404: print( 'Aborted. Cannot find the organization(%s), ' 'please refer to the short name of your ORG.' % trello_orgnization) finally: exit(0) # filter the boards by name for b in boards: if b['name'] == trello_board_name: trello_board_id = b['id'] # get trello list per issue step trello_list_backlogs = raw_input('Trello List for BACKLOGS: ') trello_list_in_progress = raw_input('Trello List for IN_PROGRESS: ') trello_list_code_review = raw_input('Trello List for CODE_REVIEW: ') trello_list_closed = raw_input('Trello List for CLOSED: ') # github repository info github_owner_name = raw_input('Github Owner Name: ') github_repo_name = raw_input('Github Repository: ') github_username = raw_input('Github Username: '******'Github Password: '******'Develop Branch: ') # generate cykle config file print('Generating cykle config file...') ctx.obj.config.add_section('trello') ctx.obj.config.set('trello', 'apikey', trello_apikey) ctx.obj.config.set('trello', 'token', trello_token) ctx.obj.config.set('trello', 'orgnization', trello_orgnization) ctx.obj.config.set('trello', 'board_id', trello_board_id) ctx.obj.config.set('trello', 'list_in_backlogs', trello_list_backlogs) ctx.obj.config.set('trello', 'list_in_progress', trello_list_in_progress) ctx.obj.config.set('trello', 'list_code_review', trello_list_code_review) ctx.obj.config.set('trello', 'list_closed', trello_list_closed) ctx.obj.config.add_section('github') ctx.obj.config.set('github', 'owner_name', github_owner_name) ctx.obj.config.set('github', 'repo_name', github_repo_name) ctx.obj.config.set('github', 'username', github_username) ctx.obj.config.set('github', 'password', base64.b64encode(github_password)) ctx.obj.config.add_section('repository') ctx.obj.config.set('repository', 'develop_branch', develop_branch) with open(CYKLE_CONFIG_FILE, 'w') as cfgfile: ctx.obj.config.write(cfgfile)
def init(ctx): if len(ctx.obj.config.items()) > 1: print 'Cykle is already initialized' exit(0) # get trello api key trello_apikey = raw_input('Trello API Key: ') # get trello token trello_api = TrelloApi(trello_apikey) token_url = trello_api.get_token_url('Cykle', expires='30days', write_access=True) webbrowser.open(token_url) trello_token = raw_input('Trello Token: ') # get trello organization trello_orgnization = raw_input('Trello Organization: ') # get trello board id trello_board_name = raw_input('Trello Board Name: ') trello_api = TrelloApi(trello_apikey, trello_token) # get all boards of the organization # if it is not a member of the organiztion, abort try: boards = trello_api.organizations.get_board(trello_orgnization) except requests.exceptions.HTTPError as e: if e.response.status_code == 401: print 'Aborted. You MUST be member of the organization(%s)' % trello_orgnization exit(0) # filter the boards by name for b in boards: if b['name'] == trello_board_name: trello_board_id = b['id'] # get trello list per issue step trello_list_in_progress = raw_input('Trello List for IN_PROGRESS: ') trello_list_code_review = raw_input('Trello List for CODE_REVIEW: ') trello_list_closed = raw_input('Trello List for CLOSED: ') # github repository info github_owner_name = raw_input('Github Owner Name: ') github_repo_name = raw_input('Github Repository: ') github_username = raw_input('Github Username: '******'Github Password: '******'Develop Branch: ') # generate cykle config file print 'generating cykle config file...' ctx.obj.config.add_section('trello') ctx.obj.config.set('trello', 'apikey', trello_apikey) ctx.obj.config.set('trello', 'token', trello_token) ctx.obj.config.set('trello', 'orgnization', trello_orgnization) ctx.obj.config.set('trello', 'board_id', trello_board_id) ctx.obj.config.set('trello', 'list_in_progress', trello_list_in_progress) ctx.obj.config.set('trello', 'list_code_review', trello_list_code_review) ctx.obj.config.set('trello', 'list_closed', trello_list_closed) ctx.obj.config.add_section('github') ctx.obj.config.set('github', 'owner_name', github_owner_name) ctx.obj.config.set('github', 'repo_name', github_repo_name) ctx.obj.config.set('github', 'username', github_username) ctx.obj.config.set('github', 'password', base64.b64encode(github_password)) ctx.obj.config.add_section('repository') ctx.obj.config.set('repository', 'develop_branch', develop_branch) with open(CYKLE_CONFIG_FILE, 'w') as cfgfile: ctx.obj.config.write(cfgfile)
import sys # You can use my API key, or get yours at https://trello.com/1/appKey/generate API_KEY = 'b51d325ae73a0264377da49c031422cf' # Initialize Trello try: with open('token.txt') as f: TOKEN = f.readlines()[0].strip() except IOError: TOKEN = None trello = TrelloApi(API_KEY) if not TOKEN: print 'Visit this, and save your token in token.txt' print trello.get_token_url('My App', expires='30days', write_access=True) sys.exit(0) trello.set_token(TOKEN) def get_list_id_from_name(name): return [ l['id'] for l in trello.boards.get_list('SkHEoGHF') if l['name'].startswith(name)][0] def move_cards(from_list, to_list): for card in trello.lists.get_card(from_list): trello.cards.update_idList(card['id'], to_list)
from trello import TrelloApi trello = TrelloApi('84586947fe8d81f7d6faa30b8e9e2056') print(trello.boards.get("t6QwKQ74")) print(trello.boards.get_list("t6QwKQ74")) print(trello.boards.get_card("t6QwKQ74")) print(trello.get_token_url('My App', expires='30days', write_access=True))
parser = argparse.ArgumentParser() parser.add_argument("-c", "--client-api-key", help="your app's client api key", action="store", required=True) parser.add_argument("-a", "--app-name", help="your app's name", action="store", required=True) parser.add_argument("-e", "--expiration", help="the token's expiration, defaults to 30days", default='30days', action="store") parser.add_argument("-w", "--write-access", help="the token has write access", default=False, action="store_true") args = vars(parser.parse_args()) print("Access the following link to generate your access token:") trello = TrelloApi(args['client_api_key']) print( trello.get_token_url(args['app_name'], expires=args['expiration'], write_access=args['write_access']))
create_time = time.strftime('%Y-%m-%d', time.localtime(card_id)) return create_time def is_in_week( create_time ): create_time = datetime.strptime(create_time, '%Y-%m-%d').date() dt = datetime.today().date() start = dt - timedelta(days=dt.weekday()) if create_time >= start and create_time <= dt: return True else: return False trello_report = open('trello_report.html', 'w') trello = TrelloApi('a4ae903d87894a87ba4c6a7b7bf617bd') token_url = trello.get_token_url('Trello Application', expires='30days', write_access=True) user = raw_input('Enter your full name: ') user_name = raw_input('Enter trello user name: ') print '\nNavigate to the following webpage (login if necessary) and click "Allow" to receive your Trello token:\n' print token_url user_token = raw_input('\nEnter your token: ') trello.set_token(user_token) boards = trello.members.get_board(user_name) enumerated_boards = [] print '\nThese are the boards available on your account:\n' i = 1
import csv from trello import TrelloApi with open('data.csv', 'rb') as csvfile: tapi = raw_input("What is your trello app key? - ") trello = TrelloApi(tapi) # get API key from https://trello.com/app-key print trello.get_token_url('Kanboard Importer', expires='30days', write_access=True) key = raw_input("What is the token? - ") trello.set_token(key) board = raw_input("What is the board ID - ") tboard = trello.boards.get(board) print trello.boards.get_list(board) listid = raw_input("What is the list ID - ") # Don't use idBoard, use id projectname = raw_input("What is the name of the Kanboard Project? - ") csvreader = csv.reader(csvfile, delimiter=',') for row in csvreader: Project = row[1] Swimlane = row[4] Name = row[13] if Project == projectname: print Name trello.cards.new(Name, listid)
def get_trello_app_token(app_key): trello = TrelloApi(app_key) print (trello.get_token_url('Trello2Text', expires='never', write_access=True)) print ("Now got to the url above and authorize the app")