[英]What does this error mean with MSAL in nodejs configuration?
I want to configure MSAL with Nodejs.我想用 Nodejs 配置 MSAL。 But I am getting error from terminal that when I execute this line.但是当我执行这一行时,我从终端收到错误。
The error I am getting is :我得到的错误是:
(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>
This is the Code:这是代码:
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);**
Here is my config file.这是我的配置文件。
{
"authorityUrl" : "https://login.microsoftonline.com/common/",
"resourceUrl" : "https://analysis.windows.net/powerbi/api",
"apiUrl" : "https://api.powerbi.com/",
"appId" : "**********************************",
"clientId" : "**********************************",
"workspaceId" : "**********************************",
"reportId" : "**********************************",
"username" : "**********************************",
"password" : "********************"
}
Here is the function where this shows the error at msal/lib-commonjs/UserAgentApplication.js File:这是在 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.
}
Please help.请帮忙。 Thanks in Advance.提前致谢。
When you create your instance of UserAgentApplication, use创建 UserAgentApplication 实例时,请使用
const msalInstance = new msal.UserAgentApplication(config);
Emphasis on the keyword new :)强调关键字 new :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.