我正在尝试将Outlook与我的React集成起来。当我试图用microsoft-graph-client实现身份验证时,会遇到以下错误。
'ImplicitMSALAuthenticationProvider‘不是从’@microsoft/microsoft-graph‘导出的(导入为'MicrosoftGraph')。
我怎样才能使这个错误发生呢?
import * as Msal from "msal";
import * as MicrosoftGraph from "@microsoft/microsoft-graph-client";
export const Authenticate = () => {
const msalConfig = {
appId: 'ea54b9e3-a1ba-44a2-b6f3-5d766f8c32e3',
scopes: [
"user.read",
"calendars.read"
]
}
const graphScopes = ["user.read", "mail.send"];
const msalApplication = new Msal.UserAgentApplication(msalConfig);
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication, options);
const AuthOptions = {
authProvider, // An instance created from previous step
};
const Client = MicrosoftGraph.Client;
return Client.initWithMiddleware(AuthOptions);
}发布于 2019-09-22 20:01:04
不幸的是,ImplicitMSALAuthenticationProvider没有显式地导出。要解决这个问题,您需要显式导入类:
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";这样您就可以实例化提供程序,
const authProvider = new ImplicitMSALAuthenticationProvider(this.userAgentApplication, { scopes });https://stackoverflow.com/questions/58049379
复制相似问题