0
votes

Is it possible to access Azure DevOps APIs which will call APIs like these:

I have create an app and allowed Azure DevOps API See here

I know I can create an app in Azure DevOps account. But the reason I want to access from here is due to the multi-tenancy.

What would be the urls to get list of Azure DevOps repositories and users

1

1 Answers

0
votes

According to my test, we can call Azure DevOps rest API with Azure Ad access token. For more details, please refer to the following steps

  1. Register an Azure AD application enter image description here

  2. Configure applications

    a. Create client secret

    b. Configure permissions

    enter image description here

  3. Get token

get code

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=<app client id>
&response_type=code
&redirect_uri=https://localhost:8000/
&response_mode=query
&scope=499b84ac-1321-427f-aa17-267ca6975798/.default
&state=12345

Get token

Post https://login.microsoftonline.com/common/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&client_id=<>
&code=<>
&redirect_uri=https://localhost:8000/
&scope=499b84ac-1321-427f-aa17-267ca6975798/.default
&client_secret=<>
  1. Call Rest API

a. list repositories

GET https://dev.azure.com/{organization}/_apis/git/repositories?api-version=6.1-preview.1
Authorization: Bearer <token>

enter image description here

b. List users

GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=6.1-preview.1
Authorization: Bearer <token>

enter image description here

For further details about Azure DevOps REST Api, please refer to the official document.