这个错误对nodejs配置中的MSAL意味着什么?

编程入门 行业动态 更新时间:2024-10-10 06:19:30

这个错误对nodejs配置中的MSAL<a href=https://www.elefans.com/category/jswz/34/1761350.html style=意味着什么?"/>

这个错误对nodejs配置中的MSAL意味着什么?

我想用Node.js配置MSAL。但是我在执行此行时从终端收到错误消息。

我得到的错误是:

(node:25500) UnhandledPromiseRejectionWarning: TypeError: this.getTelemetryManagerFromConfig is not a function
    at Object.UserAgentApplication (D:\powerbi embed\NodeJS\App Owns Data\node_modules\msal\lib-commonjs\UserAgentApplication.js:87:38)
    at Object.getAuthenticationToken (D:\powerbi embed\NodeJS\App Owns Data\authentication.js:11:31)
    at generateEmbedToken (D:\powerbi embed\NodeJS\App Owns Data\app-owns-data-sample.js:33:32)
    at Object.<anonymous> (D:\powerbi embed\NodeJS\App Owns Data\app-owns-data-sample.js:130:1)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11
(node:25500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was 
not handled with .catch(). (rejection id: 2)
(node:25500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.PS D:\powerbi embed\NodeJS\App Owns Data> 

这是代码:

var msal = require('msal');
    // var adal = require('adal-node');
    var fs = require('fs');
    var https = require('https');

    var config = require(__dirname + '/config.json');
    console.log(config);
    console.log(msal);
    **const msalInstance = msal.UserAgentApplication(config);
    console.log(msalInstance);**

这是我的配置文件。

{
    "authorityUrl" : "/",
    "resourceUrl" : "",
    "apiUrl" : "/",
    "appId" : "**********************************",
    "clientId" : "**********************************",
    "workspaceId" : "**********************************",
    "reportId" : "**********************************",
    "username" : "**********************************",
    "password" : "********************"
}

这里是在msal / lib-commonjs / UserAgentApplication.js中显示错误的函数文件:

 function UserAgentApplication(configuration) {
        // callbacks for token/error
        this.authResponseCallback = null;
        this.tokenReceivedCallback = null;
        this.errorReceivedCallback = null;
        // Set the Configuration
        this.config = Configuration_1.buildConfiguration(configuration);
        // Set the callback boolean
        this.redirectCallbacksSet = false;
        this.logger = this.config.system.logger;
        this.clientId = this.config.auth.clientId;
        this.inCookie = this.config.cache.storeAuthStateInCookie;

        **this.telemetryManager = this.getTelemetryManagerFromConfig(this.config.system.telemetry, this.clientId);** //error is referring to this line.
}

请帮助。在此先感谢。

回答如下:

[创建UserAgentApplication实例时,使用

const msalInstance = new msal.UserAgentApplication(config);

强调关键字new:)

更多推荐

这个错误对nodejs配置中的MSAL意味着什么?

本文发布于:2024-05-07 04:50:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754313.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:意味着什么   错误   nodejs   MSAL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!