Blank Auth Dialog Window in Outlook React Addin

北战南征 提交于 2019-12-23 00:51:36

问题


I have tried using Dialog API and office-js-helpers for authenticating users in my Outlook Addin React app and both of them create pop-ups for auth but they are both blank screens. Both methods return the following error

The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.

At first I thought this may be because my Auth domain was not listed in my manifest with an AppDomain tag, but I have since added it and reinstalled my add-in with no success.

Here are the two versions I have tried:

Office.context.ui.displayDialogAsync('https://foobar.auth.us-east-1.amazoncognito.com/login?client_id=MY_CLIENT_ID&response_type=code&redirect_uri=https://localhost:3000', {height: 30, width: 20});

and

authenticator.endpoints.add('Cognito', {
  redirectUrl: 'https://localhost:3000',
  baseUrl:'https://foobar.auth.us-east-1.amazoncognito.com/oauth2',
  authorizeUrl: '/authorize',
  responseType: 'token',
  tokenUrl: '/token',
  state: false,
  nonce: false,
  scope: 'openid',
  extraQueryParameters:null,
  clientId: 'MY_CLIENT_ID'
});
//for the default Microsoft endpoint
authenticator
    .authenticate('Cognito')
    .then(function (token) { return console.log('good') })
    .catch(function(err)
    {
      OfficeHelpers.Utilities.log();
      console.log("CATCH ERROR")
      console.log(JSON.stringify(err))
    });

I don't particularly care which method I use, I just need one of them to work.


回答1:


The URL that you pass to displayDialogAsync should be in the same domain as the add-in, which in your case is localhost:3000. However, that URL can be a blank page that immediately redirects to a login page. For more, see Auth with the Office Dialog.



来源:https://stackoverflow.com/questions/57581770/blank-auth-dialog-window-in-outlook-react-addin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!