2

我曾尝试使用Dialog APIoffice-js-helpers在我的 Outlook Addin React 应用程序中对用户进行身份验证,并且它们都为身份验证创建了弹出窗口,但它们都是空白屏幕。两种方法都返回以下错误

未声明纯文本文档的字符编码。如果文档包含 US-ASCII 范围之外的字符,则文档将在某些浏览器配置中呈现乱码。文件的字符编码需要在传输协议中声明或文件需要使用字节顺序标记作为编码签名。

起初我认为这可能是因为我的 Auth 域没有在我的清单中列出AppDomain,但我已经添加了它并重新安装了我的加载项,但没有成功。

这是我尝试过的两个版本:

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});

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))
    });

我并不特别关心我使用哪种方法,我只需要其中一种方法即可。

4

1 回答 1

1

您传递到的 URLdisplayDialogAsync应与加载项位于同一域中,在您的情况下为 localhost:3000。但是,该 URL 可以是立即重定向到登录页面的空白页面。有关更多信息,请参阅使用 Office 对话框进行身份验证

于 2019-08-21T02:18:26.453 回答