Azure AD B2C,AADSTS9002313:无效请求。请求畸形或无效
正如标题所说,我有问题从令牌API中恢复访问令牌, 我还尝试使用MSAL/节点库提供的方法。
我注意到我从重定向URI
中获得的代码很奇怪,在URL中,我得到 client_info
而不是 code> code
image> image-
我正在尝试3种不同的方法获取令牌。
在第一个中,我会收到标题中包含的错误,在其他两个中,我会收到以下错误 - serverrorr:invalid_grant:undefined-- [undefined]:AADB2C90090:提供的JWE不是有效的5段标记
我的代码 -
const getAuthentication = (azureConfig, azureAuthCode, confidentialClientApplication) => {
//prepare the request for authentication
debugger
tokenRequest.code = azureAuthCode
tokenRequest.grant_type = 'authorization_code';
tokenRequest.scope = [`${azureConfig.b2c._scopes.ScheduleAppointments}`];
tokenRequest.client_id = process.env.APP_CLIENT_ID;
tokenRequest.client_secret = process.env.APP_CLIENT_SECRET,
console.log(tokenRequest)
方法一号------
错误返回-AADSTS9002313:无效请求。请求是畸形或无效的
request({
url: `https://login.microsoftonline.com/${process.env.TENANT_NAME}/oauth2/v2.0/token`,
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: tokenRequest,
}, (req, res) => {console.log(res)})
方法两个-----
错误返回-ServerRorr:Invalid_grant:undefined-- [Undefined]:AADB2C90090:提供的JWE不是有效的5段tok token token
// try {
// const response = await confidentialClientApplication.acquireTokenByCode(tokenRequest)
// request.req.session.sessionParams = {user: response.account, idToken: response.idToken};
// console.log("\nAuthToken: \n" + JSON.stringify(response));
// res.render('getPatientAppointments',{showSignInButton: false, givenName: response.account.idTokenClaims.given_name});
// } catch (error) {
// console.log("\nErrorAtLogin: \n" + error);
// }
方法三
-------------------------------------------------- :未定义 - [未定义]:AADB2C90090:提供的JWE不是有效的5个段令牌
// confidentialClientApplication.acquireTokenByCode(tokenRequest).then((response)=>{
// req.session.sessionParams = {user: response.account, idToken: response.idToken};
// console.log("\nAuthToken: \n" + JSON.stringify(response));
// res.render('getPatientAppointments',{showSignInButton: false, givenName: response.account.idTokenClaims.given_name});
// }).catch((error)=>{
// console.log("\nErrorAtLogin: \n" + error);
// });
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论