3

In postman i have set simple request to access Azure DevOps API, using OAuth 2.0 security via Azure AD https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-5.1 On Azure AD application setup with permission to acess Azure DevOps API with user consent

Im getting token, however Azure DevOps API keeps returning code 203 with sign in html instead of json response. I would appreciate any suggestions

Thanks

Postman request

GET /[some_org]/_apis/projects?api=5.1 HTTP/1.1
Host: dev.azure.com 
Authorization: Bearer [something] 
User-Agent: PostmanRuntime/7.17.1 
Accept: */* 
Cache-Control: no-cache 
Postman-Token: [something] 
Accept-Encoding: gzip, deflate 
Cookie: VstsSession=[something] 
Referer: https://dev.azure.com/[some_org]/_apis/projects?api=5.1 
Connection: keep-alive cache-control: no-cache

Token get details

1

1 Answer 1

8
  1. I managed to replicate your issue using the OAuth 2.0 authentication in Postman.
  2. I started to look little more about the REST API for Azure DevOps and I found the document:

https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1

  1. Few key parts:

For Azure DevOps Services, instance is dev.azure.com/{organization}, so the pattern looks like this:

VERB https://dev.azure.com/{organization}/_apis[/{area}]/{resource}?api-version={version}

If you wish to provide the personal access token through an HTTP header, you must first convert it to a Base64 string (the following example shows how to convert to Base64 using C#). (Certain tools like Postman applies a Base64 encoding by default. If you are trying the API via such tools, Base64 encoding of the PAT is not required).

Authorization: Basic BASE64PATSTRING
  1. I configured my postman to use GET Request and Basic Authentication (and it worked)

    GET http://dev.azure.com/{organization-id}/_apis/projects?api-version=5.1

GET Request

Basic Authentication

enter image description here

More information about Personal Access Token for Azure DevOps REST API is available
here

PS And here is page regarding Azure DevOps REST API and OAuth 2.0 Authentication here There is information on how to register your application to generate OAuth 2.0 credentials required to authorize.

Sign up to request clarification or add additional context in comments.

11 Comments

Please, correct me if im wrong, but you are using basic autorization, same time as i need to use OAuth 2.0 security via Azure AD (please, check Token get details attached). I did try initially to use same link as you suggested, but no luck. Thank you
I just want to confirm, did you recevie Access Token using "Get New Access Token" (by providing Callback URL, Auth URL, Access Token URL etc... ) ?
I think she is using the post man tool to get an access token via oauth and not using PAT so token should be passed as bearer. @VictoriaPolupan are you doing that ?once you receive the token are you passing it as authorization header. Also if the authentication has been failed it should return 401 and not 203. Also what is the postman-token in your request is it same as the token? check if you have all the parameters right
if you put PAT into access token field in postman (with OAuth 2 type authentication) you get 203 error.
@Kamil, in regards to you question: yes, i received token returned from "Get new access token" call (details i'm using to get token provided under Token get details image attached to this post)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.