Invalid Hostname bad request

himanshi keyal 0 Reputation points
2024-07-04T09:21:25.3666667+00:00

Followed this document(https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=curl) to generate auth token and refresh token but encountering this error

curl --location --request POST 'https://login.microsoftonline.com/common/oauth2/v2.0/token' \

--header 'Content-Type: application/x-www-form-urlencoded' \

--data-urlencode 'client_id=5ebdb502-6d2a-48fc-874e-eaa1fe0ac03a' \

--data-urlencode 'grant_type=authorization_code' \

--data-urlencode 'scope=Mail.Send User.Read' \

--data-urlencode 'code=M.C536_BAY.2.U.394ee29a-2212-2c70-dd27-4500957c59c6' \

--data-urlencode 'redirect_uri=https://oauth.pstmn.io/v1/browser-callback' \

--data-urlencode 'client_secret=UDB8Q~rybsM1NqRO3oc5q26r7-S~0YP~gNxWIcnV'

ERROR:


curl --location --request POST 'https://login.microsoftonline.com/common/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=5ebdb502-6d2a-48fc-874e-eaa1fe0ac03a' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'scope=Mail.Send  User.Read' \
--data-urlencode 'code=M.C536_BAY.2.U.394ee29a-2212-2c70-dd27-4500957c59c6' \
--data-urlencode 'redirect_uri=https://oauth.pstmn.io/v1/browser-callback' \
--data-urlencode 'client_secret=UDB8Q~rybsM1NqRO3oc5q26r7-S~0YP~gNxWIcnV'

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

<HTML>

<HEAD>

<TITLE>Bad Request</TITLE>

<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">

</HEAD>

<BODY>

<h2>Bad Request - Invalid Hostname</h2>

<hr>

<p>HTTP Error 400. The request hostname is invalid.</p>

</BODY>

</HTML>

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
7,165 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,289 questions
0 comments No comments
{count} votes

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.