Authenticate azure devops build REST API through Azure AD access token

Abhishek Jha 26 Reputation points
2022-03-11T17:31:55.077+00:00

I need to trigger azure devops services build Rest API through azure AD access token. My devops organisation is integrated with azure AD and i have registered an app in Azure AD. using app id tenant id scope and client secret to generate access token. After generating Access token using same token to authenticate azure devops build rest api but i'm gettting 203 error .

Can someone confirm is it possible to trigger azure devops build api using azure AD token? if yes then what else i need to do?

Thanks

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,065 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Shweta Mathur 29,776 Reputation points Microsoft Employee
    2022-03-14T10:19:34.087+00:00

    Hi @Abhishek Jha ,

    Thanks for reaching out.

    I understand you are trying to call Azure AD devops build REST API using Azure AD access token and getting 203 error.

    Yes, it is possible to call Azure Devops REST API using Azure AD access token.

    The error "203 -Non-Authoritative Information" means that your access token has not right scopes to call the Azure Devops API.

    Steps to call Azure Devops REST API using Azure AD access token as follows:

    1. Register the application in Azure AD.
    2. In the app's registration screen, Add a permission to access to the Devops APIs that your application needs.
    3. In the list of APIs, select the API Azure DevOps from Microsoft APIs.
    4. In the Delegated permissions section, select the user_impersonation in the list.

    182710-image1.png

    Permission is added as below:

    182831-image2.png

    To get the access token, First get the authorize code using authorize endpoint https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize? with below parameters

    182775-image3.png

    Copy the short-lived authorization code from callback URL and get the access token using https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token

    182776-image4.png

    Make sure to use appropriate Azure DevOps resource id in the scope : 499b84ac-1321-427f-aa17-267ca6975798/user_impersonation to get the authorized access token to call Azure Devops REST API

    182750-image5.png

    Hope this will help.

    Thanks,
    Shweta

    ----------------------------------------------

    Please remember to "Accept Answer" if answer helped you.


  2. Sajan Sureshnath 0 Reputation points
    2023-10-23T12:44:30.0166667+00:00

    @Shweta Mathur @mayank agarwal I am facing the exact same issue. Have you been able to find a solution?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.