I am able to clone the Devops Repo via PAT toke in below way : git clone https://<>@dev.azure.com/organisation/project/_git/myGitRepo
But I am trying to clone the repo via Service principal for which I am using the below logic :
$resource="499b84ac-1321-427f-aa17-267ca6975798"
$TenantId=" "
$ClientId=" "
$ClientSecret=" "
$TokenUri = "https://login.microsoftonline.com/$TenantID/oauth2/token/"
$Body = "client_id=$ClientId&client_secret=$ClientSecret&resource=$Resource&grant_type=client_credentials"
$TokenResult = Invoke-RestMethod -Uri $TokenUri -Body $Body -Method "POST"
$AccesToken = $TokenResult.access_token
$URI= "https://[email protected]/organisation/project/_git/myGitRepo"
git clone $URI
I am getting the below error :
remote: TF401019: The Git repository with name or identifier myGitRepo does not exist or you do not have permissions for the operation you are attempting. fatal: repository 'https://dev.azure.com/organisation/project/_git/myGitRepo/' not found
Note : The service principal is added as a Project administrator within the Devops Project and Stakeholder access level at Organization level
The free access level of Stakeholder cannot use the Azure Repos feature in this organization.
See more information About access levels - Azure DevOps | Microsoft Learn and Stakeholder access quick reference,
Stakeholder access is available to support free access to a limited set of features by an unlimited set of stakeholders. In general, Stakeholder access users gain limited access to Azure Boards and collaboration tools. They have no access to code repositories.
Please assign the service principal at least the Basic license for a test again.