AngularMSALB2C无法获取有效载荷(payload)
创始人
2024-10-28 15:31:51
0
  1. 确认在B2C策略中已经为身份验证响应启用了有效载荷(参见下面的代码示例)。

  2. 确认在Angular的配置中设置了正确的clientId和authorityUrl(参见下面的代码示例)。

  3. 确认在组件中正确调用了MSAL库中的acquireTokenSilent()方法,以从B2C获取身份验证令牌并解析有效载荷。

代码示例:

在B2C策略中启用有效载荷:







在Angular中的配置:

export const environment = {
  production: false,
  clientId: 'your-client-id-here',
  authorityUrl: 'https://your-b2c-tenant.b2clogin.com/your-b2c-tenant.onmicrosoft.com/b2c_1a_signinup/',
  redirectUri: 'http://localhost:4200',
  scopes: ['openid', 'email', 'profile', 'offline_access', 'https://your-b2c-tenant.onmicrosoft.com/api/user_impersonation']
};

在组件中调用acquireTokenSilent()方法:

  this.authService.acquireTokenSilent(['https://your-b2c-tenant.onmicrosoft.com/api/user_impersonation'])
    .then((response) => {
      console.log('ACQUIRED TOKEN', response);
      const payload = JSON.parse(Utils.base64DecodeStringUrl(response.idToken.split('.')[1]));
      console.log('PAYLOAD', payload);
    })
    .catch((error) => {
      console.log('ERROR ACQUIRING TOKEN', error);
    });

相关内容

热门资讯

第2分钟辅助!pokemmo脚... 第2分钟辅助!pokemmo脚本,hhpoker可以控制牌吗,经验教程(果真有挂)1、hhpoker...
第1分钟辅助!wepoker私... 第1分钟辅助!wepoker私人局怎么玩,佛手在线大菠萝智能辅助器,资料教程(有挂神器)所有人都在同...
六分钟辅助!hhpoker德州... 六分钟辅助!hhpoker德州透视挂,wepokerplus透视脚本免费,指南教程(有挂方式)运we...
6分钟辅助!hhpoker软件... 6分钟辅助!hhpoker软件安装包,wepoker免费脚本弱密码,总结教程(有挂分析)1)wepo...
第五分钟辅助!aapoker插... 第五分钟辅助!aapoker插件下载,wepoker有辅助器吗,大纲教程(有挂工具)1、完成wepo...
第4分钟辅助!wepoker永... 第4分钟辅助!wepoker永久免费脚本,wepoker买钻石有用吗,绝活教程(有挂方针)1、下载好...
八分钟辅助!wpk作弊,wep... 八分钟辅助!wpk作弊,wepokerplus辅助,法门教程(有挂神器)1、wepokerplus辅...
七分钟辅助!wepoker私局... 七分钟辅助!wepoker私局辅助,hhpoker辅助器视频,经验教程(有挂教学)该软件可以轻松地帮...
第3分钟辅助!wepokerp... 第3分钟辅助!wepokerplus开挂,we poker游戏下,步骤教程(有挂讲解)1、wepok...
第5分钟辅助!poker辅助器... 第5分钟辅助!poker辅助器免费安装,epoker有透视吗,方案教程(真实有挂)1、游戏颠覆性的策...