从JS单页应用程序向azure-ad-b2c策略发送声明的示例 [英] Example of sending claim to azure-ad-b2c policy from JS single page application

查看:85
本文介绍了从JS单页应用程序向azure-ad-b2c策略发送声明的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用msal js库将SPA重定向到b2c策略.

I'm using msal js library to redirect SPA to b2c policy.

我找不到从JavaScript应用程序向b2c策略(例如extension_Brand)发送一些自定义声明的示例.

I can't find an example of sending some custom claim to the b2c policy (like extension_Brand) from javascript application.

我发现的是.NET示例:

What I have found is .NET example: https://github.com/Azure-Samples/active-directory-b2c-advanced-policies/blob/d62c3f9e573ac8b5a9adc1565c6254f632e2a531/wingtipgamesb2c/src/WingTipMusicWebApplication/Startup.cs#L108 But it uses .NET library.

哪个JS库可以向b2c策略发送声明?

Which JS library can send claim to the b2c policy?

推荐答案

我不知道任何JS示例.

There are no JS examples that I know of.

可以使用 MSAL.js 通过

You can use MSAL.js to send claims to B2C via the extraQueryParameters arg on loginPop, loginRedirect, etc.

对服务器进行Ajax调用以获得JWT,然后将该JWT传递到B2C.

Make an ajax call to the server to get a JWT and then pass along that JWT to B2C.

将索赔通过


示例JS代码

服务器端示例仅发出一个HTTP请求,这意味着您可以在JavaScript中执行相同的操作:

The server-side example is just making an HTTP request which means you can do the same thing in JavaScript:

var client_assertion_type = encodeURIComponent("urn:ietf:params:oauth:client-assertion-type:jwt-bearer");

var jwtQueryParams = "client_assertion_type=" + client_assertion_type + "&client_assertion=" + jwt;

msalApp.loginRedirect(myScopes, jwtQueryParams);

这篇关于从JS单页应用程序向azure-ad-b2c策略发送声明的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆