- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 MSAL 为我的单页应用程序添加 SSO,目的是获取用于解析 Microsoft SaaS 订阅的 Oauth2 token 。我已经根据此示例存储库配置了我的代码:https://github.com/Azure-Samples/ms-identity-javascript-v2 。这使用 MSAL 2.0,而不是 1.X 版本。
这是在 /signup
页面上运行的相关代码片段:
var config = {
auth: {
clientId: <MY_CLIENT_ID>,
authority: "https://login.microsoftonline.com/common",
redirectUri: <APP_URL> + "/signup",
},
cache: {
cacheLocation: "sessionStorage",
storeAuthStateInCookie: false,
}
};
var msalInstance = new msal.PublicClientApplication(config);
msalInstance.loginPopup(["openid", "profile", "User.Read"]).then((response) => {
console.log(response)
}).catch(error => {
console.error(error);
});
在我的应用程序中调用此代码,我使用弹出窗口成功登录,但出现以下错误:ServerError: invalid_client: 70002 - [2020-09-03 16:55:35Z]: AADSTS70002: The提供的请求必须包含“client_secret”输入参数。
我可以看到底层网络调用是https://login.microsoftonline.com/common/oauth2/v2.0/token
,具有以下表单数据:
client_id: <MY_CLIENT_ID>
redirect_uri: <APP_URL>/signup
scope: openid profile
code: <some value>
code_verifier: <some value>
grant_type: authorization_code
client_info: 1
client-request-id: <some value>
基于此处的文档 https://learn.microsoft.com/en-us/advertising/guides/authentication-oauth-identity-platform?view=bingads-13#request-accesstoken ,此调用应该有一个可配置的 client_secret
参数,这会导致我收到的错误。
我从 Azure 门户上的应用程序获得了所需的客户端 key 。我的问题是,如何在我的 config
对象中配置客户端 key ?我无法在网上找到任何示例,并且我尝试盲目地将 clientSecret
添加为我的配置中 auth
下的 key ,这并没有将其传递给 login.microsoftonline.com
调用。
更新
经过一番深入研究,我意识到我的设置的根本问题是我试图使用 authorization grant flow请求 token 但需要使用 client credentials flow 。将 token 获取移至后端(并在那里使用客户端 key )之后,以及 this followup thread 中的更多帮助我能够按预期进行 SSO 和 token 获取。
最佳答案
关于azure - Microsoft 身份验证库 (MSAL) 登录弹出 : Error The "provided request must include a ' client_secret' input parameter. |,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63728609/
我从 GitHub 下载了示例以试验 Azure AD B2C https://github.com/Azure-Samples/active-directory-b2c-dotnet-webapp-
为了在我的 JavaScript 代码中使用 MSAL 获取访问 token ,我拼凑了大量教程和文档。这是我的研究结果。 最佳答案 npm 安装@azure/msal 从@azure/msal 导入
我正在编写一个 Chrome 扩展程序,它需要访问需要 AAD 访问 token 的 ASP.NET Core Web API。我正在尝试使用 msal NPM 包提供身份验证流程,以便用户可以使用他
我没有从使用 MSAL 库的 UserAgentApplication 实例的 loginPopup(requestObj) 获得 loginResponse。 Azure 示例用作 https://
我对 OAuth2 以及 AccessToken 和 RefreshToken 的概念比较熟悉。 看起来 MSAL 在使用 ClientApplicationBase.AcquireTokenSile
我使用了 msal.js 文件(版本 1.0.3),但是没有调用 authCallback 函数, var clientApplication = new Msal.UserAgentApplicat
Dynamics 365 的门户功能提供了使用 Azure AD B2C 登录的功能。这是我对其控制能力有限的产品功能,据我所知,该功能是在没有 MSAL 的情况下实现的。 在门户上下文中,我尝试使用
我正在尝试遵循 Microsoft active-directory 的教程 将客户端 ID 和 key 输入代码并运行代码后,它会将我带到登录页面,我使用凭据登录,但出现以下错误: "errorCo
我正在尝试遵循 Microsoft active-directory 的教程 将客户端 ID 和 key 输入代码并运行代码后,它会将我带到登录页面,我使用凭据登录,但出现以下错误: "errorCo
我正在尝试使用 Azure MSAL 浏览器 js CDN 将对象初始化为 PublicClientApplication。但我发现 Msal 未定义。 CDN:https://alcdn.msaut
我尝试使用此处提供的代码:https://github.com/Azure-Samples/active-directory-javascript-singlepageapp-dotnet-webap
@azure/msal-browser 2.14.1@azure/msal-react 1.0.0-beta.2 我们正在使用自定义 B2C 政策 当我使用 PublicClientApplicati
我有一个使用 msal 0.1.2 的 angular7 应用程序。用户间歇性地无法访问任何需要身份验证的内容,当您查看开发人员工具网络选项卡时,您可以看到一个 GET 请求来获取 https://l
@azure/msal-browser 2.14.1@azure/msal-react 1.0.0-beta.2 我们正在使用自定义 B2C 政策 当我使用 PublicClientApplicati
我想使用应用程序 ID 和 secret 对 AAD 用户进行身份验证,以通过 MSAL 访问 powerBi 资源。所以我想获取访问 token 并将其缓存在 SQL Db 中。 经历了 docum
我尝试包含 Azure AD 进行登录,但在运行 npm install @azure/msal-browser @azure/msal-angular 以及 npm install @azure/m
我尝试包含 Azure AD 进行登录,但在运行 npm install @azure/msal-browser @azure/msal-angular 以及 npm install @azure/m
我想安装 @azure/msal-angular 以使用 Angular 作为前端来使用 azure B2C 身份验证,但是当我尝试安装该包时,它给了我一个错误 npm ERR! code E
我想安装 @azure/msal-angular 以使用 Angular 作为前端来使用 azure B2C 身份验证,但是当我尝试安装该包时,它给了我一个错误 npm ERR! code E
使用msal.js库(Microsoft身份验证库),可以通过哪种方法知道给定用户是否已经登录?我的意图是如果用户的凭据已经保存在浏览器的存储中,则避免显示登录弹出窗口 我目前的做法: functio
我是一名优秀的程序员,十分优秀!