My end goal is to authenticate a AD user with his/her username and password credentials only, After research, got to know about ROPC flow, so I created an App Registration, used its tenantID, clientID and such parameters and hit the API with username and password in PostMan. I was successful in getting the tokens. Great.
I need to hit this API from my web application and get tokens.(Getting token is not my objective, but to just authenticate a user). When I try to hit this URL from my React Client, I get CORS error.
What should I do to solve this issue?
I created an App Service, but helpless, couldn't get understanding of what's happening
I tried to reproduce the same in my environment and got the below results:
I generated access token via ROPC Flow using below Parameters:
To resolve the
CORSerror, try adding<allowed-headers>tag defined in yourCORSpolicy:Check whether you are passing wrong token and check whether you are authorized to perform the action.
If still the issue persists, try not exposing the
client_secretand call the Api.Reference:
Enable Cross-Origin Requests (CORS) | Microsoft Learn