You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过GitHub App自动创建Pull Request遇403权限问题求助

解决GitHub App创建Pull Request返回403的问题

核心原因

你的GitHub App当前没有足够权限创建Pull Request——创建Issue只需要基础仓库访问权限,但PR操作需要明确配置Pull requests的写入权限。

解决步骤

    1. 配置GitHub App权限
      进入你的GitHub App设置页面,找到「Permissions & events」:
    • 在「Repository permissions」分类下找到「Pull requests」,将权限级别设置为「Write」
    • 保存更改后,必须重新将App安装到目标仓库,确保新权限生效
    1. 重新生成Installation Token
      旧的token不会自动继承新配置的权限,需要重新获取installation access token,确保它包含Pull requests的写入权限
    1. 验证分支与仓库参数
      确认代码里的repo参数格式为owner/repo-name,同时base_branch和test_branch都存在于目标仓库中,且分支没有设置阻止App操作的保护规则

确认后的代码(权限配置正确即可运行)

# github app
@client = Octokit::Client.new(:access_token => "更新后的installation access token")

response = @client.create_pull_request(repo, base_branch, "test_branch", pr_title, pr_body)

内容的提问来源于stack exchange,提问作者huseyin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 02:10:35