如何检索 GitHub 存储库机密并打印其值?

问题描述 投票:0回答:1

在使用 PyGithub 包时,我尝试获取存储库秘密并尝试获取它们的值,但我无法做到这一点,但我能够访问 GitHub 存储库变量的值

使用这段代码,我可以从存储库中检索变量:

from github import Github
code = ""
github_token = f'ghp_{code}'
github = Github(github_token)

repo = github.get_repo('bhupender/repo_name')

secret_value = repo.get_variable("DEMO_TOKEN")

print(secret_value.value)

我正在查看一些文档,其中写道我们无法从存储库中访问机密。

我如何访问它或者有其他解决方法吗?

python github
1个回答
0
投票

它不是 PyGithub,而是 github 本身的限制。

现有秘密无法在 Web 界面中泄露,也无法通过

gh
CLI 应用程序

https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions

您只能列出、设置或删除现有秘密

© www.soinside.com 2019 - 2024. All rights reserved.