I need to work with Azure DevOps Repository (clone, push, pull) from non-interactive script. I've found only the solution to authenticate using PAT (https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows):
$MyPat = 'yourPAT'
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("`:$MyPat"))
git -c http.extraHeader="Authorization: Basic $B64Pat" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
But I don't want to use Basic authentication. Are there more secure solutions?
Expect to authenticate using OAuth by service principal using client credentials flow to generate access token and use it in http.extraHeader