Pavindu
Pavindu

Reputation: 3112

'ImplicitMSALAuthenticationProvider' is not exported from '@microsoft/microsoft-graph-client'

I'm trying to integrate Outlook API with my React App. When I'm trying to implement authentication with microsoft-graph-client, I'm greeted with the following error.

'ImplicitMSALAuthenticationProvider' is not exported from '@microsoft/microsoft-graph-client' (imported as 'MicrosoftGraph')

How can I make this error go?

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);
}

Upvotes: 3

Views: 743

Answers (1)

Darrel Miller
Darrel Miller

Reputation: 142094

Unfortunately, the ImplicitMSALAuthenticationProvider is not exported explicitly. To work around this you need to explicitly import the class:

import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";

this then allows you to instantiate the provider,

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

Upvotes: 2

Related Questions