def generate_token():
ui.info_1("Creating new GitHub token")
username = ui.ask_string("Please enter you GitHub username")
password = getpass.getpass("Password: ")
scopes = ['repo']
# Need a different note for each device, otherwise
# gh_api.authorize() will fail
note = "tsrc-" + str(uuid.uuid4())
note_url = "https://supertanker.github.io/tsrc"
def ask_2fa():
return ui.ask_string("2FA code: ")
authorization = github3.authorize(username, password, scopes,
note=note, note_url=note_url,
two_factor_callback=ask_2fa)
return authorization.token
评论列表
文章目录