github - 即使使用 oauth 令牌,Github api 也会返回错误的凭据
问题描述
更新:即使是这样的请求也会获得错误的凭据 ==>
curl -H "Authorization: token [token]" https://api.github.com
================
我在我的 iOS 应用程序中向 GitHub OAuth 提出了这样的请求:
URL: https://github.com/login/oauth/authorize,
params: client_id: ****, redirect_uri: app_url, scope: "repo", state: "0"
从 Safari 重定向后,我得到一个代码。我需要访问两件事:
- 用户数据,如电子邮件等。同时更新用户数据。
- 公共和私有存储库中的存储库和提交列表。
我提出以下要求:
URL: https://api.github.com/user , 获取并打补丁 Header: Authorization: token [code]
URL: https://api.github.com/repos/:username/:repoName
Header: Authorization: token [code]
但不幸的是,我收到以下错误:
401, Unauthorized
{
"message": "Bad credentials",
"documentation_url": "https://developer.github.com/v3"
}
有什么问题,我该如何解决?
解决方案
推荐阅读
- c# - 根据类型将 JSON 文件中的每一行更改为常量
- javascript - 为什么这个 JavaScript 映射不是无限循环?
- angular-service-worker - 如何修改服务工作者文件而不用 ng build --prod 覆盖它
- javascript - variable.split(',') 的错误不是函数
- google-bigquery - 如何使用另一个 bigquery 表中的数据更新嵌套的 bigquery 列
- amazon-s3 - AWS S3 - 没有 gz 压缩的 Athena
- c++ - 为什么这个正在运行的代码不打印字符串的最后一个值/?
- java - 在没有互联网连接的计算机上使用 Scala
- javascript - javascript 在异步计算后决定调用 stopPropagation
- android - 如何将字符串从一个 android 模拟器发送到不同设备中的另一个模拟器?