我们正在编写一个脚本,在执行时使用ROPC流通过提供用户凭据和检索访问令牌来验证用户登录到Microsoft帐户而没有任何UI。其主要目标是使用Microsoft图形API登录和显示用户邮件。我们已经通过将用户重定向到微软登录页面的方式尝试了这一点,但是我们想要一种非交互的方式来实现这一点。
const AccToken= await pca.acquireTokenByUsernamePassword(usernamePasswordRequest)在代码中遇到上面的一行后,它将给我以下错误:
2022年9月21日08:47格林尼治时间:@azure/msal-node@1.14.0 : Info - acquireTokenByUsernamePassword调用Wed,21 9月2022 08:02:47 GMT:@azure/msal-node@1.14.0 :详细- initializeRequestScopes调用Wed,21 9月2022 08:02:47 GMT : 749ab7af-b49a-4154-9ea1-773f778b1190:@azure/msal-节点@1.14.0:详细- buildOauthClientConfiguration调用Wed,2022年9月21日08:02:47 GMT : 749ab7af-b49a-4154-9ea1-773f778b1190:@azure/msal-node@1.14.0:https://login.microsoftonline.com/{Tenant_id} Wed,21 https://login.microsoftonline.com/{Tenant_id} 2022 08:02:47 GMT : 749ab7af-b49a-4154-9ea1-773f778b1190:@azure/msal-node@1.14.0:https://login.microsoftonline.com/{Tenant_id} _this =_super.call( errorString) \x{e76f}这个;^
ClientAuthError: endpoints_resolution_error: Error:无法解析端点。请检查网络,再试一次。详细信息: ClientAuthError: openid_config_error:无法检索端点。检查您的权限并验证.著名/openid-配置端点返回所需的端点。试图从:https://login.microsoftonline.com/{Tenant_id}/v2.0/.well-known/openid-configuration检索端点
我想知道为什么会发生这种情况,或者在没有任何用户交互的情况下,我可以采取什么不同的方法来登录。
发布于 2022-10-04 12:21:49
如果您正在调用的端点/URL无效,则通常会发生错误Endpoints_resolution_error 。
确保复制端点用于OpenID,如下所示:

请尝试使用msal-node版本1.9.0并检查它是否解决了这个问题。
E 222,并调试小提琴以检查出了什么问题。<>H 223H 124如果您的应用程序是多租户,然后根据您的需求使用d25而不是tenant_id。<>H 229f请注意,当授权服务器与 blog.兼容时,MSAL节点支持ROPC。
尝试替换代码中的下面一行以访问Graph:
const AccToken = await pca.acquireTokenByUsernamePassword({ scopes: [], password: config.userPassword, username: config.userAccount });检查配置/应用程序参数是否匹配以下内容:
auth: {
clientId: "clientID",
authority: "https://login.microsoftonline.com/tenantID",
clientSecret: "clientsecret",
knownAuthorities: "https://login.microsoftonline.com/tenantID"
},https://stackoverflow.com/questions/73797692
复制相似问题