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

撤销GitHub应用授权时遭遇404错误的技术求助

撤销GitHub应用授权API调用问题

遇到的困惑

  • 官方文档列出3个用于撤销授权的相关端点,但访问api.github.com时并未将其列为有效端点:
    • 删除应用令牌
    • 删除应用授权
    • 撤销安装访问令牌
  • 尝试调用这3个端点,全部返回404错误
  • 其中两个端点的文档说明:

访问此端点必须使用Basic Authentication,将应用的client_id和client_secret作为用户名和密码。
但对应的示例代码均未包含client_secret,仅使用了client_id

我的调用代码

chrome.storage.local.get(["github_token"]).then((result) => {
    let token = result.github_token;
    if (token) {
        let client_id = import.meta.env.VITE_CLIENT_ID
        const URL = `https://api.github.com/applications/${client_id}/grant`;    
        const xhr = new XMLHttpRequest();
        xhr.addEventListener('readystatechange', function () {
        if (xhr.readyState === 4) {
            if (xhr.status === 204) {
                console.log("logged out")
                navigate('/auth')
            } else {
                console.log("awww fuck")
            }
        }
        });
        xhr.open('DELETE', URL, true);
        xhr.setRequestHeader('Authorization', `token ${token}`);
        xhr.setRequestHeader('Accept', 'application/vnd.github.v3+json');
        xhr.send();
    } else {
        // smth went wrong
    }
})

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 09:52:17