Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure函数验证typescript中的令牌_Typescript_Azure Functions_Azure Ad B2c - Fatal编程技术网

Azure函数验证typescript中的令牌

Azure函数验证typescript中的令牌,typescript,azure-functions,azure-ad-b2c,Typescript,Azure Functions,Azure Ad B2c,我正在使用Azure静态Web应用程序构建一个网站,Azure B2C正在处理登录/注册。API是类型脚本Azure函数(Azure静态web应用程序的一部分)。我有一些API调用,只有在用户登录时才能访问,因此我将承载令牌发送到后端 如何在后端(typescript)针对我的Azure B2C租户验证此令牌,以便在其有效时将数据发送回用户?我建议检查MSAL库中的JS/TS: 如果您想使用Azure AD B2C访问令牌,我们可以使用包Azure AD验证令牌来实现它 比如说 import {

我正在使用Azure静态Web应用程序构建一个网站,Azure B2C正在处理登录/注册。API是类型脚本Azure函数(Azure静态web应用程序的一部分)。我有一些API调用,只有在用户登录时才能访问,因此我将承载令牌发送到后端


如何在后端(typescript)针对我的Azure B2C租户验证此令牌,以便在其有效时将数据发送回用户?

我建议检查MSAL库中的JS/TS:


如果您想使用Azure AD B2C访问令牌,我们可以使用包
Azure AD验证令牌来实现它

比如说

import { verify, VerifyOptions } from 'azure-ad-verify-token';
 
const options: VerifyOptions = {
  jwksUri: 'https://<tenantName>.b2clogin.com/<tenantName>.onmicrosoft.com/discovery/v2.0/keys?p=b2c_1_signupsignin1',
  issuer: 'https://<tenantName>.b2clogin.com/<tennat id>/v2.0/',
  audience: '<Identifies the intended recipient of the token. For Azure AD B2C, the audience is the application ID>'
};
var res = await verify(token, options);
 context.log(res);
从“azure ad验证令牌”导入{verify,VerifyOptions};
常量选项:验证选项={
jwksUri:'https://.b2clogin.com/.onmicrosoft.com/discovery/v2.0/keys?p=b2c_1_signupsignin1',
发行人:'https://.b2clogin.com//v2.0/',
观众:''
};
var res=等待验证(令牌、选项);
context.log(res);


有关更多详细信息,请参阅和

感谢链接,但它们不包括使用azure功能的令牌验证