如何从对话框窗口中从
我正在为MS Word构建Office 365加载项。它需要生成用于调用API的SSO令牌。
在运行任务窗口窗口本身时,我能够生成一个SSO令牌。但是,从对话框窗口调用时,相同的代码在以下错误中失败。
我在Taskpane中有一个按钮,它打开了这样的对话框窗口:
Office.context.ui.displayDialogAsync('https://myAddinDomain/myDialog.html');
对话框窗口然后试图获得这样的SSO令牌:
await OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: true });
但是,以上功能会引发以下错误:
{
name: 'Permission Denied',
message: "You don't have sufficient permissions for this action.",
code: 7000
}
我在此阶段的假设是到期到此处概述的限制您无法在对话框中打开对话框,也许这就是getAccessToken
函数正在尝试尝试做。这可以解释为什么我能够在Taskpane中获得令牌,而不是对话框。
如果是这种情况,我如何从对话框窗口中生成一个SSO令牌?
I'm building an Office 365 Add-in for MS Word. It needs to generate a SSO token which is used to invoke an API.
I'm able generate an SSO token when running a Taskpane window itself. However, the same code fails with the below error when being invoked from a dialog window.
I've got a button in the Taskpane which opens a dialog window like this:
Office.context.ui.displayDialogAsync('https://myAddinDomain/myDialog.html');
The dialog window then tries to get an SSO token like this:
await OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: true });
However the following error is thrown by the above function:
{
name: 'Permission Denied',
message: "You don't have sufficient permissions for this action.",
code: 7000
}
My assumption at this stage is that it's due to the limitation outlined here that you cannot open a dialog from within a dialog and perhaps that's what the getAccessToken
function is trying to do. That would explain why I'm able to get the token within the taskpane but not the dialog.
If that's the case how do I generate an SSO token from the dialog window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在加载项中的任何事件处理程序中调用
store> striefuntime.auth.auth.getAccestoken
方法,该方法触发您的对话框要显示,然后将令牌作为参数传递给对话框窗口。显示对话框并尝试调用SSO并不是一个好主意,该对话也可以显示对话框窗口。
You can call the
OfficeRuntime.auth.getAccessToken
method from any event handler in the add-in which triggers your dialog to be displayed and then pass a token as a parameter to the dialog window.That is not really a good idea to display a dialog and then try to call SSO which could also display dialog windows.
尤金是正确的。另外,请注意您链接到的文章:
因此,您无法从对话框内部调用GetAccessToken。
Eugene is correct. Also, note this from the article that you linked to:
So, you can't call getAccessToken from inside a dialog.