Microsoft graph api ';隐式MSLAuthenticationProvider';不是从'@microsoft/microsoft图形客户端';

Microsoft graph api ';隐式MSLAuthenticationProvider';不是从'@microsoft/microsoft图形客户端';,microsoft-graph-api,Microsoft Graph Api,我正在尝试将Outlook API与我的React应用程序集成。当我尝试使用microsoft graph client实现身份验证时,遇到以下错误 “隐式MSLAuthenticationProvider”未从导出 “@microsoft/microsoft图形客户端”(作为“MicrosoftGraph”导入) 我怎样才能使这个错误消失 从“Msal”导入*作为Msal; 将*作为MicrosoftGraph从“@microsoft/microsoft graph client”导入; 导出

我正在尝试将Outlook API与我的React应用程序集成。当我尝试使用
microsoft graph client
实现身份验证时,遇到以下错误

“隐式MSLAuthenticationProvider”未从导出 “@microsoft/microsoft图形客户端”(作为“MicrosoftGraph”导入)

我怎样才能使这个错误消失

从“Msal”导入*作为Msal;
将*作为MicrosoftGraph从“@microsoft/microsoft graph client”导入;
导出常量身份验证=()=>{
常量msalConfig={
附件:“ea54b9e3-a1ba-44a2-b6f3-5d766f8c32e3”,
范围:[
“user.read”,
“日历。阅读”
]
}
const graphScopes=[“user.read”,“mail.send”];
const msalApplication=新的Msal.UserAgentApplication(msalConfig);
const options=新的MicrosoftGraph.MSALAuthenticationProviderOptions(图形范围);
const authProvider=新的MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication,选项);
常量AuthOptions={
authProvider,//从上一步创建的实例
};
const Client=MicrosoftGraph.Client;
返回Client.initWithMiddleware(AuthOptions);
}

不幸的是,隐式MSLAuthenticationProvider没有显式导出。要解决此问题,需要显式导入类:

import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
这样您就可以实例化提供程序

const authProvider = new ImplicitMSALAuthenticationProvider(this.userAgentApplication, { scopes });

在我的例子中,这也是必需的:从“@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions”导入{MSALAuthenticationProviderOptions}