2017-08-15 5 views
1

github apiを使用して組織にユーザーを追加する際に問題があります。 私はGET requestを使って、私が所有者である組織の会員資格を取得しました。しかし、私は応答を得る403 githubの組織apiを使用すると禁止

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" 
} 

を取得しますか?

答えて

1

これは、OAuthアプリケーションのトークンを使用して組織に対してアクションを実行している理由です。

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

が、問題のアプリケーションをホワイトリストに登録されていない:その組織が有効になって、この機能を持っています。そのため、この機能はあなたが組織のメンバーではないように行動し、APIを動作させます。

組織の問題のアプリケーションをホワイトリストに登録するか、その機能を無効にする必要があります。

+0

ありがとう、私は開発者サイトでこのリンクが見つかりませんでした。これは、アプリケーションに権限が与えられた後に動作します。 –

関連する問題