[英]GitHub GraphQL API returning forbidden when using access token from GithubAuthProvider
I'm using GithubAuthProvider with the added scope repo
to get the user's access token which is later used to access the GitHub GraphQL API (the GitHub App has the permissions for Contents and Metadata set to Read-only). I'm using GithubAuthProvider with the added scope
repo
to get the user's access token which is later used to access the GitHub GraphQL API (the GitHub App has the permissions for Contents and Metadata set to Read-only).
The problem is when I'm trying to list private repos.问题是当我试图列出私人回购时。 The API returns an empty array as if I don't have the required permissions.
API 返回一个空数组,就好像我没有所需的权限一样。 Moreover, when I try to list branches of a user's repo it returns an error of type
FORBIDDEN
.此外,当我尝试列出用户存储库的分支时,它会返回类型为
FORBIDDEN
的错误。
Query:询问:
query {
viewer {
repository(name: "some-repo") {
refs(refPrefix: "refs/heads/", first: 10) {
nodes {
name
}
}
}
}
}
Response:回复:
{
"data": {
"viewer": {
"repository": {
"refs": null
}
}
},
"errors": [
{
"type": "FORBIDDEN",
"path": [
"viewer",
"repository",
"refs"
],
"extensions": {
"saml_failure": false
},
"locations": [
{
"line": 7,
"column": 7
}
],
"message": "Resource not accessible by integration"
}
]
}
What am I missing?我错过了什么?
For GitHub GraphQL API, only scope repo
may not be enough.对于 GitHub GraphQL API,仅 scope
repo
可能不够。
Following are scopes requested for reference.以下是要求参考的范围。 Authenticating with GraphQL
使用 GraphQL 进行身份验证
user
public_repo
repo
repo_deployment
repo:status
read:repo_hook
read:org
read:public_key
read:gpg_key
The API returns an empty array as if I don't have the required permissions.
I wonder whether you are query under the viewer
.不知您是否在
viewer
下查询。 viewer
can get the private repos he/she owned . viewer
可以获得他/她拥有的私人回购。 For repos owned by other people, you can try对于其他人拥有的repos,您可以尝试
repository(name: "repo-name", owner: "login") {
name
}
It will return NOT_FOUND
error if you don't have the required permissions.如果您没有所需的权限,它将返回
NOT_FOUND
错误。
Your query works fine for me:)您的查询对我来说很好:)
It turns out I read through the Firebase instructions too fast and created a Github App instead of an OAuth App.事实证明,我过快地阅读了 Firebase 指令并创建了 Github 应用程序而不是 OAuth 应用程序。
It's now working as it should.它现在可以正常工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.