匿名访问 AzDevOps 公共回购原始内容 URL

问题描述 投票:0回答:0

可以公开访问 公开可见项目 存储库中文件的 URL,或使用 其余 API 获取其内容。

示例:https://dev.azure.com/ayn/PowerShell/_git/AzIaaS?path=/README.md&_a=preview

fetch("https://dev.azure.com/ayn/PowerShell/_apis/git/repositories/4d348186-f42e-4ea5-9ed0-ec47530caee1/items?path=/README.md&api-version=7.1-preview.1")
      .then(response => response.text())
      .then(data => document.getElementById('code').textContent = data)
<pre id="code"></pre>

但是,如果没有 PAT,此答案中共享的方法就不起作用。下面的 URL 在用户登录时在浏览器上工作 但在其他情况下则不起作用,即使它是一个 public 存储库。

原始内容 URL:

https://dev.azure.com/ayn/PowerShell/_apis/sourceProviders/tfsgit/filecontents?&repository=AzIaaS&commitOrBranch=main&api-version=7.0&path=/README.md

有没有办法获取可以从浏览器匿名访问的

public 存储库文件的原始内容 URL?

azure azure-devops azure-devops-rest-api azure-authentication azure-repos
© www.soinside.com 2019 - 2024. All rights reserved.