我想使用Groovy,HttpBuilder和REST API来访问我们公司的onsidte GitHub设备.GitHub开发人员的网站:https://developer.github.com/v3/,显示了以下URL:https://api.github.com.因此,如果我公司的GitHub URL是:http://github.mycompany.com,那么我的REST API端点URL是什么?例如,如果我想列出所有用户,那么正确的URL是什么?
当我访问此URL:https://github.mycompany.com/api/v3时,它给出了一个错误:
github.mycompany.com拒绝连接.ERR_CONNECTION_REFUSED
Von*_*onC 12
根据" API Enterprise 2.5 ":
除管理控制台 API端点外的所有API端点都以以下URL为前缀:
http(s)://hostname/api/v3/
Run Code Online (Sandbox Code Playgroud)
但您需要进行身份验证:
认证
您的Enterprise安装的API端点接受与 GitHub.com API 相同的身份验证方法.具体来说,您可以使用OAuth令牌(可以使用Authorizations API创建)或基本身份验证对自己进行身份验证.
每个Enterprise API端点只能由GitHub Enterprise站点管理员访问,但Management Console API 除外,它只能通过管理控制台密码访问.
TLTR; 这些是端点
+----+------------------------------------------+--------------------------------+
| | Enterprise | GitHub |
+----+------------------------------------------+--------------------------------+
| v3 | https://[YOUR_HOST]/api/v3 | https://api.github.com |
| v4 | https://[YOUR_HOST]/api/graphql | https://api.github.com/graphql |
+----+------------------------------------------+--------------------------------+
Run Code Online (Sandbox Code Playgroud)
如果您想尝试,这里有一些示例。您需要创建一个ACCESS_TOKEN
企业
curl -H "Authorization: bearer [ACCESS_TOKEN]" https://[YOUR_HOST]/api/v3/organizations
curl -H "authorization: bearer [ACCESS_TOKEN]" https://[YOUR_HOST]/api/graphql -d "{\"query\": \"query { viewer { login } }\"}"
Run Code Online (Sandbox Code Playgroud)
GitHub
curl -H "Authorization: bearer [ACCESS_TOKEN]" https://api.github.com/organizations
curl -H "authorization: bearer [ACCESS_TOKEN]" https://api.github.com/graphql -d "{\"query\": \"query { viewer { login } }\"}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9699 次 |
| 最近记录: |