gpt4 book ai didi

github - 在 github 上使用 organizations api 时出现 403 Forbidden

转载 作者:行者123 更新时间:2023-12-04 17:50:09 26 4
gpt4 key购买 nike

我在使用 github api 将用户添加到组织时遇到了一些问题。我用过 GET request获得我所拥有的组织的成员(member)身份。但是我得到了回应

GET http://api.github.com/orgs/romanc-org/memberships/gromanc
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

-- response --
403 Forbidden
Server: GitHub.com
Date: Tue, 15 Aug 2017 10:34:33 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Status: 403 Forbidden
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4995
X-RateLimit-Reset: 1502793489
X-OAuth-Scopes: admin:org, repo, user
X-Accepted-OAuth-Scopes: admin:org, read:org, repo, user, write:org
X-OAuth-Client-Id: 212a8581bdca54d1f503
X-GitHub-Media-Type: github.v3; format=json
access-control-expose-headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
content-security-policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Runtime-rack: 0.027377
Content-Encoding: gzip
X-GitHub-Request-Id: 2F55:2B87:2E85F4A:6FC7673:5992CE39

{
"message": "You must be a member of romanc-org to see membership information for gromanc.",
"documentation_url": "https://developer.github.com/v3/orgs/members/#get-organization-membership"
}

我尝试获取其他用户的状态,但因同样的错误而失败。

我也试过PUT a user to the organization但是得到

PUT http://api.github.com/orgs/romanc-org/memberships/bt080527
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
{
"login": "bt080527",
"id": 30951532,
"avatar_url": "https://avatars2.githubusercontent.com/u/30951532?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/bt080527",
"html_url": "https://github.com/bt080527",
"followers_url": "https://api.github.com/users/bt080527/followers",
"following_url": "https://api.github.com/users/bt080527/following{/other_user}",
"gists_url": "https://api.github.com/users/bt080527/gists{/gist_id}",
"starred_url": "https://api.github.com/users/bt080527/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/bt080527/subscriptions",
"organizations_url": "https://api.github.com/users/bt080527/orgs",
"repos_url": "https://api.github.com/users/bt080527/repos",
"events_url": "https://api.github.com/users/bt080527/events{/privacy}",
"received_events_url": "https://api.github.com/users/bt080527/received_events",
"type": "User",
"site_admin": false,
"name": null,
"company": null,
"blog": "",
"location": null,
"email": null,
"hireable": null,
"bio": null,
"public_repos": 0,
"public_gists": 0,
"followers": 0,
"following": 0,
"created_at": "2017-08-12T09:57:40Z",
"updated_at": "2017-08-12T09:57:40Z"
}

-- response --
403 Forbidden
Server: GitHub.com
Date: Tue, 15 Aug 2017 10:47:51 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Status: 403 Forbidden
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4997
X-RateLimit-Reset: 1502797454
X-OAuth-Scopes: admin:org, repo, user
X-Accepted-OAuth-Scopes: admin:org, repo
X-OAuth-Client-Id: 212a8581bdca54d1f503
X-GitHub-Media-Type: github.v3; format=json
access-control-expose-headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
content-security-policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Runtime-rack: 0.200124
Content-Encoding: gzip
X-GitHub-Request-Id: 2FED:2B88:139A091:2BBE319:5992D157

{
"message": "You must be an admin to add or update an organization membership.",
"documentation_url": "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership"
}

我做错了什么?

最佳答案

发生这种情况的原因是您正在使用 OAuth 应用程序的 token 对组织执行操作。该组织启用了此功能:

https://help.github.com/articles/about-oauth-app-access-restrictions/

但有问题的应用程序尚未列入白名单。因此,该功能启动并使 API 表现得就像您不是该组织的成员一样。

您需要为组织将相关应用程序列入白名单,或者禁用该功能。

关于github - 在 github 上使用 organizations api 时出现 403 Forbidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45691715/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com