我在尝试使用 GitHub OAuth API 将代码交换为令牌时遇到问题。每当我向 URL https://github.com/login/oauth/access_token 发出请求时,我都会收到 404 {"error":"Not Found"} 错误响应。
我尝试过的:
我尝试使用各种方法来解决此问题,包括:
相关信息:
Octokit 版本:3.1.2
cURL 调用示例:
$ curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "User-Agent: axios/0.21.1" \
-H "Accept: application/json" \
-d "client_id=XXXXXX" \
-d "client_secret=XXXXXXX" \
-d "grant_type=authorization_code" \
-d "code=XXXXXX" \
-d "redirect_uri=https://example.com" \
https://github.com/login/oauth/access_token
{"error":"Not Found"}
仔细检查url请求参数
验证您的代币
检查速率限制
https://github.com/login/oauth/access_token您收到此错误是因为您的端点失败或不存在。
POST https://github.com/login/oauth/access_token使用这个正确的端点来检查它是否正常工作
并验证 HTTP 方法。