List of Repositories - Authorize Rest API calls using Job Access Token

 Author: Akhil M Anil || DevOps Engineer

Getting the complete list of Repository names in Azure DevOps Project using REST Api and Publishing as a CSV file.

In the last blog I have talked about Authorizing REST API call using Job Access Tokens. If missed, please find that blog here: Job Access Tokens. In this blog we will use Job Access Token to Authorize Rest API call and retrieve the list of repositories. 

Full code can be found in GitHub: Repository-List

Steps:

  • Push the developed pipeline code (azure-pipelines-repos.yml) and python code (repos.py) to Azure Repos.

Job Authorization Scope for Job Access token.

In order to access repositories using system access token, we need to change our default job authorization scope. In my last blog I have already mentioned about Job Authorization Scopes, feel free to take a look. 
  • To set job authorization scope at the organization level for all projects, choose Organization settings > Pipelines > Settings.
  • To set job authorization scope for a specific project, choose Project settings > Pipelines > Settings.
  • We need to disable Protect access to repositories in order to access the repositories using system access token.
  • Navigate to Organization settings> Pipelines > Settings. and disable Protect access to repositories in YAML pipelines.
  • Navigate to Project settings> Pipelines > Settings. and validate the Protect access to repositories is disabled, if not make sure you disable the same.
  • Run the pipeline
    • Pipeline will authenticate with ADO using Job access token and fetch the API results and publish as an artifact.



Comments

Popular posts from this blog

Configure an Azure DevOps self-hosted Windows agent in Docker

Install Java silently using powershell in Azure Windows VM