mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 16:18:02 +01:00
Keep backwards compatability by going back to "--token" for classic.
Allow "file://" uri for "--token-fine".
This commit is contained in:
@@ -58,9 +58,10 @@ CLI Usage is as follows::
|
||||
-p PASSWORD, --password PASSWORD
|
||||
password for basic auth. If a username is given but
|
||||
not a password, the password will be prompted for.
|
||||
-f TOKEN_FINE, --token-fine TOKEN
|
||||
fine-grained personal access token
|
||||
-t TOKEN_CLASSIC, --token-classic TOKEN
|
||||
-f TOKEN_FINE, --token-fine TOKEN_FINE
|
||||
fine-grained personal access token or path to token
|
||||
(file://...)
|
||||
-t TOKEN_CLASSIC, --token TOKEN_CLASSIC
|
||||
personal access, OAuth, or JSON Web token, or path to
|
||||
token (file://...)
|
||||
--as-app authenticate as github app instead of as a user.
|
||||
|
||||
@@ -150,7 +150,7 @@ def parse_args(args=None):
|
||||
'If a username is given but not a password, the '
|
||||
'password will be prompted for.')
|
||||
parser.add_argument('-t',
|
||||
'--token-classic',
|
||||
'--token',
|
||||
dest='token_classic',
|
||||
help='personal access, OAuth, or JSON Web token, or path to token (file://...)') # noqa
|
||||
parser.add_argument('-f',
|
||||
@@ -362,6 +362,11 @@ def get_auth(args, encode=True, for_git_cli=False):
|
||||
elif args.osx_keychain_item_account:
|
||||
raise Exception('You must specify both name and account fields for osx keychain password items')
|
||||
elif args.token_fine:
|
||||
_path_specifier = 'file://'
|
||||
if args.token_fine.startswith(_path_specifier):
|
||||
args.token_fine = open(args.token_fine[len(_path_specifier):],
|
||||
'rt').readline().strip()
|
||||
|
||||
if args.token_fine.startswith("github_pat_"):
|
||||
auth = args.token_fine
|
||||
else:
|
||||
@@ -371,6 +376,7 @@ def get_auth(args, encode=True, for_git_cli=False):
|
||||
if args.token_classic.startswith(_path_specifier):
|
||||
args.token_classic = open(args.token_classic[len(_path_specifier):],
|
||||
'rt').readline().strip()
|
||||
|
||||
if not args.as_app:
|
||||
auth = args.token_classic + ':' + 'x-oauth-basic'
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user