Using preferred choice of Authentication library for authenticating with Microsoft is possible.
Create own implementation of Authentication provider which implements AuthenticationProvider interface.
// MyAuthenticationProvider.tsimport{AuthenticationProvider}from"@microsoft/microsoft-graph-client";classMyAuthenticationProviderimplementsAuthenticationProvider{/** * This method will get called before every request to the msgraph server * This should return a Promise that resolves to an accessToken (in case of success) or rejects with error (in case of failure) * Basically this method will contain the implementation for getting and refreshing accessTokens */publicasyncgetAccessToken(): Promise<string>{}}
Pass instance of MyAuthenticationProvider while initializing.
import{MyAuthenticationProvider}from"./MyAuthenticationProvider";letclientOptions: ClientOptions={authProvider: newMyAuthenticationProvider(),};constclient=Client.initWithMiddleware(clientOptions);