github.py 文件源码

python
阅读 43 收藏 0 点赞 0 评论 0

项目:tsrc 作者: SuperTanker 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号