可以通过如下接口添加协作者:https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
端点:/repos/:owner/:repo/collaborators/:username
但是如何添加团队访问权限,这绝对可以通过"Settings > Collaborators & Teams“中的web界面来实现
发布于 2020-01-18 05:03:08
实际上,我认为这可以通过api以这种方式完成,它只需要标头和指示权限的数据。
curl -H "Accept: application/vnd.github.v3+json" -u YourUserName:YourPersonalAccessToken -X PUT -d '{"permission":"write"}' https://api.github.com/teams/$team_id/repos/$org_name/$repo或者,在Python中:
import requests, json
data = json.dumps({"permission": 'read'}) . #could be 'write', etc..
headers = {
'content-type': 'application/json',
'accept': 'application/vnd.github.v3+json, text/plain, */*'
}
auth_tuple = (username, access_token)
url = f"https://api.github.com/teams/{team_id}/repos/{org_name}/{repo}"
requests.put(url, auth=auth_tuple, data=data, headers=headers)https://stackoverflow.com/questions/59655726
复制相似问题