最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

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

IT培训 admin 11浏览 0评论

这个错误对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意味着什么?

我想用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:)

发布评论

评论列表 (0)

  1. 暂无评论