'Unable to authenticate to Azure DevOps using Personal Access Token (302 redirect)

I followed the Azure DevOps docs for how to create a Personal Access Token, convert the token to Base64 and GET repo branches, but I cannot successfully request.

What am I missing?

PowerAutomate Action: HTTP Request

  • Where myOrg, myProject and myRepoID are actual values

enter image description here

Error: 302 Redirect

enter image description here

Error Text:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://spsprodcus3.vssps.visualstudio.com/_signin?realm=dev.azure.com&amp;reply_to=https%3A%2F%2Fdev.azure.com%2FmyOrg%2FmyProject%2F_apis%2Fgit%2Frepositories%2FmyRepoID%2Frefs%3Fapi-version%3D6.0&amp;redirect=1&amp;hid=<longGUID>&amp;context=<longGUIDctx=<longGUID">here</a>.</h2>
</body></html>

EDIT 1:

  • Tried adding the Content-Type header and adding the auth as a special header
  • Still same error

enter image description here

EDIT 2:

  • Tried adding the PAT to Basic auth but the Username is required

enter image description here

EDIT 3:

  • I found that even though above action fails, the response Location header contains a URL that resolves correctly:

    • https://spsprodcus3.vssps.visualstudio.com/_signin?realm=dev.azure.com&reply_to=https%3A%2F%2Fdev.azure.com%2FmyOrg%2FmyProject%2F_apis%2Fgit%2Frepositories%3Fapi-version%3D6.0&redirect=1&mkt=en-US&hid=LONG_GUID&context=LONG_GUIDctx=LONG_GUID
  • BUT when this URL is piped to a subsequent HTTP action, it results in a 203 response that does not include the REST response!

enter image description here

EDIT 4: THIS WORKED

  • Added a . to the Basic username Authentication
  • Regenerated the ADO Personal Access Token, saved the new value in Key Vault

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source