Error getting access_token with "Bad Request - Invalid URL HTTP Error 400" on Microsoft authentication endpoint

Ibn Ishaq 20 Reputation points
2024-09-23T09:58:57.03+00:00

I am trying to retrieve the access_token and refresh_token from the Microsoft authentication endpoint using Postman. However, I am getting the following error message:

HTTP Error 400. The request URL is invalid

I have attached an image showing how I am sending the request along with this question. Any ideas on what could be the issue?
User's image

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,734 questions
{count} votes

Accepted answer
  1. Navya 10,790 Reputation points Microsoft Vendor
    2024-09-24T11:49:05.6033333+00:00

    Hi @Ibn Ishaq

    Thank you for posting this in Microsoft Q&A.

    I understand you are trying to retrieve the access_token and refresh_token from the Microsoft authentication endpoint using Postman but getting error HTTP Error 400-The request URL is invalid.According to the screenshot you provided, it appears that you have included the content-type in the URL. You should place the content-type parameter in the header section.

    Request an JWT access token using the Postman

    Set method as POST.
    URL: https://login.microsoftonline.com/consumers/oauth2/v2.0/token
    Headers -> Content-Type: application/x-www-form-urlencoded
    client_id= Application_id
    scope=user.read
    code= {The code acquired in previous step}
    redirect_uri= https://localhost
    grant_type=authorization_code

    User's image

    Hope this helps. Do let us know if you any further queries.

    Thanks,

    Navya.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.