Getting error while getting access token using OAuth 2.0 device code flow

TechnoGenics Integrations 1 Reputation point
2021-06-22T12:51:32.903+00:00

I am trying to get access token via OAuth 2.0 device authorization grant flow https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#authenticating-the-user and i am getting this error:

{
"error": "invalid_client",
"error_description": "AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.\r\nTrace ID: 3706b400-f39e-465a-8585-e9c2fe34ba00\r\nCorrelation ID: 619aa720-c135-48b8-af2b-3115920197b0\r\nTimestamp: 2021-06-22 12:07:04Z",
"error_codes": [
7000218
],
"timestamp": "",
"trace_id": ",
"correlation_id": "",
"error_uri": "https://login.microsoftonline.com/error?code=7000218"
}

I successfully got the device code and signed user consent using:

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/devicecode
Content-Type: application/x-www-form-urlencoded

client_id= my application id
scope=user.read%20openid%20profile

And using device_code to request for accees token but running into the above mentioned error
The request I am is as follows:
108068-code.png

Why i am getting this error, as this API does not support client_secret as a parameter. Also i don't even have client_secret (that is why i am using this authorization flow) which i can put there.

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

1 answer

Sort by: Most helpful
  1. Danstan Onyango 3,821 Reputation points Microsoft Employee
    2021-06-23T13:03:58.793+00:00

    You must be using a public client without allowing public flows on your app. Try going to the AAD app and flip Allow public client flows to Yes. See screenshot below.

    108629-allow-public-clients.png


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.