0

I generated a project with yo office to create an office add-in based on Angular. When I add the @microsoft/mgt libs to that project (as per https://learn.microsoft.com/en-us/graph/toolkit/get-started/use-toolkit-with-angular) I get an error saying

SCRIPT5022: SCRIPT5022: Office.js has not fully loaded. Your app must call "Office.onReady()" as part of it's loading sequence (or set the "Office.initialize" function). If your app has this functionality, try reloading this page.

This happens when I add

  Providers.globalProvider = new MsalProvider({
    clientId: environment.clientID
  });

to the ngOnInit() of the app.component.ts. Removing this statement loads Office just fine and lets me use my Addin. Is there anything I can do in my code to fix this? Or is this an imcompatibility between the two Microsoft libraries?

kjoetools
  • 528
  • 1
  • 6
  • 12
  • In my scenario, i initialized the provider in my code, so i provided the permission scopes in an array in the scopes property. Adding the Javascript sample: import {Providers, MsalProvider } from "@microsoft/mgt"; Providers.globalProvider = new MsalProvider({ clientId: 'YOUR_CLIENT_ID' scopes:['user.read','people.read'] }); – Dev Dec 18 '20 at 16:01
  • Does it helped? – Dev Dec 19 '20 at 17:34
  • The example I added was a shorter version of what i actually used. I added scopes to the provider the same way you suggested but that doesn't make a difference. Does your setup work correctly with office.js and the @microsoft/mgt libs? – kjoetools Jan 05 '21 at 14:11
  • I'm still stumped about this issue. Anybody have a clue how to solve it? – kjoetools Jan 20 '21 at 08:37

0 Answers0