使用 GitHub OAuth API 交换代码换取令牌时遇到 404 错误“Not Found”

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

我在尝试使用 GitHub OAuth API 将代码交换为令牌时遇到问题。每当我向 URL https://github.com/login/oauth/access_token 发出请求时,我都会收到 404 {"error":"Not Found"} 错误响应。

我尝试过的:

我尝试使用各种方法来解决此问题,包括:

  1. 进行 cURL 调用。
  2. 将新的 Octokit() 构造函数与 createOAuthUserAuth() 结合使用。

相关信息:

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"}
github github-api github-app github-oauth
2个回答
0
投票

仔细检查url请求参数

验证您的代币

检查速率限制


0
投票

https://github.com/login/oauth/access_token您收到此错误是因为您的端点失败或不存在。

POST https://github.com/login/oauth/access_token使用这个正确的端点来检查它是否正常工作

并验证 HTTP 方法。

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