I'm using Angular 9 to create Office Add-Ins, and the application runs SUCCESSFULLY in Outlook windows, but when I try to open the Authentication dialogue (login with microsoft), it redirects to the default windows browser instead of the internal popup. (Office.context.ui is not working)
How can I open login with microsoft dialog box using in Angular on Login button click like this? (WITHOUT Yoeman)
Office.context.ui.displayDialogAsync(url, options, callback);
My code:
Index.html:
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
main.ts
declare const Office: any;
Office.initialize = function () {
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
};
app.module.ts
imports:[
MsalModule.forRoot({
auth: {
clientId: environment.uiClienId, // This is your client ID
authority: 'https://login.microsoftonline.com/' + environment.tenantId, // This is your tenant ID
redirectUri: environment.redirectUrl// This is your redirect URI
},
cache: {
cacheLocation: 'localStorage',
storeAuthStateInCookie: isIE, // Set to true for Internet Explorer 11
},
framework:{
isAngular:true
}
}, {
popUp: true,
consentScopes: [
'user.read',
'openid',
'profile',
],
unprotectedResources: [],
protectedResourceMap: [
['https://graph.microsoft.com/v1.0/me', ['user.read']]
],
extraQueryParameters: {}
})]
app.component.ts
myFunction() {
this.zone.run(() => {
});
login.component.ts -> Button click function (try with both function)
this.authService.loginRedirect({
extraScopesToConsent: ["user.read", "openid", "profile"]
});
OR
this.authService.loginPopup({
extraScopesToConsent: ["user.read", "openid", "profile"]
});