How can I let guest users access my Azure DevOps REST API using a registered application?

Andrew Tarr 1 Reputation point
2022-09-15T21:22:59.653+00:00

I have registered an application in my organization's Azure and I have set up OAuth using Angular/ASP.NET to use that application. There are two things I'm trying to achieve:

  1. I want my organization's DevOps/Azure AD users to be able to log in, retrieve access tokens, and use those tokens to access my organization's DevOps via the REST API. This works.
  2. I want my organization's guest users to be able to log in, and do all the same stuff. This doesn't work.

On the second item, my guest users are able to log in and retrieve access tokens, but the access tokens they retrieve only seem to be usable on their own organization's DevOps. So, I'm Org A, and my guest is from Org B. When my guest logs into my application, they can only access Org B's API. If they attempt to access Org A's API, they will get a 203 response with the "Azure DevOps Services Sign In" screen returned. I want them to access Org A's API.

I have been following this "Authenticate with Azure Active Directory (Azure AD) tokens" (https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/manage-personal-access-tokens-via-api?view=azure-devops#authenticate-with-azure-active-directory-azure-ad-tokens).

Where am I going wrong here? Please send help.

Community Center Not monitored
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2022-09-15T21:24:09.21+00:00

    Devops / TFS is not currently supported here on Q&A. The product group for Azure DevOps / TFS actively monitors questions over at
    https://developercommunity.visualstudio.com/report?space=21&entry=problem
    https://developercommunity.visualstudio.com/report?space=22&entry=problem
    https://azure.microsoft.com/en-in/support/devops/

    --please don't forget to upvote and Accept as answer if the reply is helpful--


  2. JamesTran-MSFT 36,906 Reputation points Microsoft Employee Moderator
    2022-09-22T16:51:48.823+00:00

    @Andrew Tarr
    Thank you for following up on this!

    I'm not too familiar with curl requests or the DevOps REST API, but from the doc that you followed, it shares an example of how to make the curl request. Can you see if a Guest user can make a call using the same format for the curl or GET request?

    Example: Use Azure AD access token to make the List PATs request:

    # The example doesn't contain a the  --locaiton or --request GET parameter.  
    curl -H "Authorization: Bearer <Azure AD token>" "https://vssps.dev.azure.com/{organization}/_apis/Tokens/Pats?api-version=6.1-preview"  
    

    Use the access token:

    #This doc describes how to use the Access Token. Since the request is specifically a GET, curl isn't used.  
    GET https://dev.azure.com/myaccount/myproject/_apis/build-release/builds?api-version=3.0  
    Authorization: Bearer {access_token}  
    

    I'd also make sure that your Access Token is valid and decodes correctly - https://jwt.ms/.

    As shared by @Anonymous , since the issue is with the DevOps REST API, I'd also recommend reaching out to our DevOps experts via their Developer Community.

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.

    0 comments No comments

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.