Search code examples
azurerestazure-devopsoauth-2.0postman

Postman OAuth 2.0 "request url is empty" error even though successful authentication


I authenticate using OAuth 2.0 authorization code workflow successfully and get redirected back to Postman. Here is more information on the Azure DevOps REST API I am trying to do.

In the console, I get an error: request URL is empty

I do not see the authorization code in the response for me to parse, but if I expand the error message and look in the Request Body > code, my authorization code is there!

I am able to use the authorization code to successfully obtain an Access Token as well.

Steps to reproduce error:

  1. I set all of the values in the OAuth 2.0 form
  2. I click Get New Access Token
  3. I get redirected to my browser to accept
  4. I get a successful authentication & get redirected back to Postman
  5. I get the Authorization code in the request body of a console error (I also get the auth code in the URL after authenticating)

On step #5, I expect to get redirected back to Postman successfully with the authorization code in the body of the message.

enter image description here enter image description here enter image description here

EDIT: The solution below works for the Azure API with a scope of https://graph.microsoft.com. If the scope is https://app.vssps.visualstudio.com (which is what I'm using), the solution will not work oddly enough.


Solution

  • Please try my steps to get access token with OAuth 2.0 in Postman.

    POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
    

    Callback URL: the Redirect URI in Application > Authentication. It is required. Don't select Authorize using browser.

    Auth URL: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize

    Access Token URL: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token

    enter image description here

    enter image description here

    For more information, you could refer to the blog which uses oauth2 v1.0.