As I venture into creating a SharePoint web part with the latest SharePoint framework that integrates the Microsoft Graph API as outlined here:
I'm utilizing a sample for reference.
The initial steps involved generating a new project using the Yeoman generator for SharePoint.
I proceeded to install Adal: npm install adal-angular
Followed by installing typings for Adal: typings install adal --source dt --global --save
After which, I copied and pasted relevant snippets from the WebPart.tsx file:
const AuthenticationContext = require('adal-angular');
import adalConfig from '../AdalConfig';
import { IAdalConfig } from '../../IAdalConfig';
import '../../WebPartAuthenticationContext';
export default class ReactClient extends React.Component<IReactClientProps, IReactClientState> {
private authCtx: adal.AuthenticationContext;
constructor(props: IReactClientProps, state: IReactClientState) {
super(props);
}
this.state = {
loading: false,
error: null,
signedIn: false
};
const config: IAdalConfig = adalConfig;
config.popUp = true;
config.webPartId = this.props.webPartId;
config.callback = (error: any, token: string): void => {
this.setState((previousState: IReactClientState, currentProps: IReactClientProps): IReactClientState => {
previousState.error = error;
previousState.signedIn = !(!this.authCtx.getCachedUser());
return previousState;
});
};
this.authCtx = new AuthenticationContext(config);
AuthenticationContext.prototype._singletonInstance = undefined;
}
While declaring:
private authCtx: adal.AuthenticationContext;
poses no issues in recognizing the 'adal' namespace defined in the Adal type file.
However, when executing:
this.authCtx = new AuthenticationContext(config);
An error arises stating: Cannot use 'new' with an expression whose type lacks a call or construct signature
Despite the presence of the constructor in the Adal type file, the reason behind this issue remains obscure to me. Seeking insights from the community to resolve this.
Thank you,