I am trying to make REST calls to Azure DevOps (Build Pipeline) through my PAT and it works (c# and Postman).
But, I don't want to use my PAT anymore, so how can I know make REST calls from C# (and postman) without PAT and I don't want Interactive flow here every time (I can ok to obtain access token through interactive flow once) ?
Is it possible to make calls to Azure Devops through some access token (but how) or any other way ?
CodePudding user response:
This article contains a list of all possible authentication mechanisms with appropriate samples. You can start from here and find the most relevant approach for your application.
CodePudding user response:
For authentication mechanism please refer to Choosing the right authentication mechanism for details.
Besides, we can also use the OAuth token inside the script to call the REST APIs in pipeline.
First of all, we need to check the option Allow scripts to access the OAuth token
. This enables scripts and other processes launched by tasks to access the OAuth token through the System.AccessToken
variable. This setting is somewhere hidden in the Additional options of the Agent Job.
For example, within a PowerShell script we can retrieve the System.AccessToken
variable and use it to authenticate against the Azure DevOps REST API. Refer to Use the OAuth token to access the REST API for details.
If you cannot register an app in Azure DevOps services, then no other way to use the OAuth to authenticate in REST API.