具有curl的Visual Studio Team Services REST API
我可以使用Google的DHC扩展程序或代码访问Team Services API,但使用curl无法实现相同的功能.
I can access Team Services API with Google's DHC Extension or in code but can't achieve the same with curl.
到目前为止,我已经尝试过:
so far I've tried:
curl -H授权:承载MY_ACCESS_TOKEN" https://MYINSTANCE.VisualStudio.com/DefaultCollection/_apis/projects?api-version = 2.0
curl -H "Authorization: Bearer MY_ACCESS_TOKEN" https://MYINSTANCE.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0
我不断收到对象移至...."的结果.
i'm keep getting "Object moved to ...." result.
我该如何解决?
我之前遇到过此问题,可以通过将" Bearer "更改为" Basic "来使其正常工作.
I met this issue before and get it work by changing "Bearer" to "Basic".
curl -H "Authorization: Basic <TOKEN>" https://xxxxxx.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0
更新:当前,VSO Rest API仅支持基本身份验证和OAuth 2.0授权访问.您可以使用基本身份验证,也可以使用curl从VSO获取OAuth2.0访问令牌.请参阅此链接以获取详细信息:使用OAuth 2.0授权对REST API的访问.
Update: Current, VSO Rest API only support Basic authentication and Authorize access with OAuth 2.0. You'd either use Basic Auth or use curl to fetch OAuth2.0 access token from VSO. Refer to this link for details: Authorize access to REST APIs with OAuth 2.0.
我刚刚使用个人访问令牌尝试了DHC,但收到以下消息:很抱歉,Chrome API不允许获取用于重定向的响应正文."因此,您可能需要清除浏览器的cookie和缓存,然后尝试查看承载者是否可以与DHC中的VSO Rest API一起使用.
And I just tried DHC with personal access token, but get following message: "We are sorry, but Chrome API does not allow to get a response body for redirect." So you may need to clear your browser cookies and caches and then try to see if bearer can works with VSO Rest API in DHC.