python - 使用 PyPi 通过 git clone 传递令牌的正确方法是什么?
问题描述
我正在使用 PyPi 克隆一个 github 存储库,但它是一个私有存储库。所以我还需要用我的令牌授权它。我找不到任何如何通过克隆请求传递令牌的示例。
import git
git.Git('/local/file/path').clone('git@github.com:sample-repo.git', token=(mytoken))
这给出了一个错误
"GitCommandError: Cmd('git') failed due to: exit code(129)"
cmdline: git clone --token=mytoken git@github.com:sample-repo.git
stderr: 'error: unknown option token=mytoken'
当我尝试克隆公共存储库时,它可以在没有令牌的情况下正常工作。所以这里唯一的问题是如何将令牌传递给上述请求。这是可能的还是有其他方法可以在 python 脚本中授权 git clone ?我的目标是自动化一个克隆 github 存储库的过程,使用一些 API 调用生成一些文件,将这些文件添加并提交到存储库,所有这些都在同一个 python 脚本中。
解决方案
感谢评论,我能够使用 https url 而不是 ssh url 克隆我的存储库,并且无需令牌即可工作。
import git
git.Git('/local/file/path').clone('https://github.com/sample-repo')
推荐阅读
- scala - spark persist() (然后动作)真的持续存在吗?
- http - cookie 集中可能存在的漏洞
- python-3.x - 如何消除由相同数字形成但排列的幻方
- javascript - 如何使用 Redux 动态添加输入?
- javascript - 如何在复选框和文本输入中使用“其他”选项
- python - 如何将具有重复索引的 DataFrame 转换为 MultiIndex DataFrame?
- r - 创建一个在其他列中查找值的新列
- sql - 将转换后的格式更改为 ISO 日期 - SQL Server
- javascript - 使用 javascript 创建带有图像标签的数组
- angular - 组件组成 - 验证问题