diff --git a/plugin/vira.vim b/plugin/vira.vim index bf66bc9..9595b5f 100644 --- a/plugin/vira.vim +++ b/plugin/vira.vim @@ -51,13 +51,13 @@ command! -nargs=0 -bang ViraTodo call vira#_todo() command! -nargs=0 -bang ViraTodos call vira#_todos() " Sets -command! -nargs=0 -bang ViraSetAssignee call vira#_menu('assign_issue'); -command! -nargs=0 -bang ViraSetComponent call vira#_menu('component'); -command! -nargs=0 -bang ViraSetEpic call vira#_menu('epic'); -command! -nargs=0 -bang ViraSetPriority call vira#_menu('priority'); -command! -nargs=0 -bang ViraSetStatus call vira#_menu('set_status'); -command! -nargs=0 -bang ViraSetType call vira#_menu('issuetype'); -command! -nargs=0 -bang ViraSetVersion call vira#_menu('version'); +command! -nargs=0 -bang ViraSetAssignee call vira#_menu('assign_issue') +command! -nargs=0 -bang ViraSetComponent call vira#_menu('component') +command! -nargs=0 -bang ViraSetEpic call vira#_menu('epic') +command! -nargs=0 -bang ViraSetPriority call vira#_menu('priority') +command! -nargs=0 -bang ViraSetStatus call vira#_menu('set_status') +command! -nargs=0 -bang ViraSetType call vira#_menu('issuetype') +command! -nargs=0 -bang ViraSetVersion call vira#_menu('version') " Edit command! -nargs=0 -bang ViraEditDescription call vira#_prompt_start('description') diff --git a/python/Vira/vira_api.py b/python/Vira/vira_api.py index 044f71c..3644c49 100644 --- a/python/Vira/vira_api.py +++ b/python/Vira/vira_api.py @@ -179,6 +179,10 @@ def connect(self, server): self.versions = set() self.users_type = '' + # Login arguments + auth_kwargs = {} + option_kwargs = {} + try: # Specify whether the server's TLS certificate needs to be verified if self.vira_servers[server].get('skip_cert_verify'): @@ -188,12 +192,21 @@ def connect(self, server): cert_verify = True # Get auth for current server - username = self.vira_servers[server].get('username') - password_cmd = self.vira_servers[server].get('password_cmd') - if password_cmd: - password = run_command(password_cmd)['stdout'].strip().split('\n')[0] + if not self.vira_servers[server].get('access_token_cmd') and not self.vira_servers[server].get('access_token'): + username = self.vira_servers[server].get('username') + password_cmd = self.vira_servers[server].get('password_cmd') + if password_cmd: + password = run_command(password_cmd)['stdout'].strip().split('\n')[0] + else: + password = self.vira_servers[server]['password'] + auth_kwargs['basic_auth'] = (username, password) else: - password = self.vira_servers[server]['password'] + token_cmd = self.vira_servers[server].get('access_token_cmd') + if token_cmd: + access_token = run_command(token_cmd)['stdout'].strip().split('\n')[0] + else: + access_token = self.vira_servers[server]['access_token'] + option_kwargs = {"headers": {"Authorization": "Bearer %s" % access_token}} except: self.msg_server_fail() raise