We are writing a script that on executed uses the ROPC flow to authenticate user login into Microsoft account without any UI, by giving the user credentials and retrieve access token. The main goal is to login and display users mails by using Microsoft graph API. We have tried this with a UI by redirecting user to Microsoft login page and it works but we want a non-interactive way of achieving this.
const AccToken= await pca.acquireTokenByUsernamePassword(usernamePasswordRequest)
After encountering the above line in code it is giving me the following error:
[Wed, 21 Sep 2022 08:02:47 GMT] : @azure/msal-node@1.14.0 : Info - acquireTokenByUsernamePassword called [Wed, 21 Sep 2022 08:02:47 GMT] : @azure/msal-node@1.14.0 : Verbose - initializeRequestScopes called [Wed, 21 Sep 2022 08:02:47 GMT] : [749ab7af-b49a-4154-9ea1-773f778b1190] : @azure/msal-node@1.14.0 : Verbose - buildOauthClientConfiguration called [Wed, 21 Sep 2022 08:02:47 GMT] : [749ab7af-b49a-4154-9ea1-773f778b1190] : @azure/msal-node@1.14.0 : Verbose - building oauth client configuration with the authority: https://login.microsoftonline.com/{Tenant_id} [Wed, 21 Sep 2022 08:02:47 GMT] : [749ab7af-b49a-4154-9ea1-773f778b1190] : @azure/msal-node@1.14.0 : Verbose - createAuthority called /home/abc/Desktop/git/ExpressWebApp/node_modules/@azure/msal-common/dist/index.cjs.js:509 _this = _super.call(this, errorString) || this; ^
ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientAuthError: openid_config_error: Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints. Attempted to retrieve endpoints from: https://login.microsoftonline.com/{Tenant_id}/v2.0/.well-known/openid-configuration
I would like to know why this is occurring or if there is any different approach that i can take for logging in without any user-interaction