我正在创建一个 SSO 插件,我只是调用它来尝试一下 (getAccessToken):
async function getUserData() {
try {
let usertokenEncoded = await OfficeRuntime.auth.getAccessToken();
let usertoken = jwt_decode(usertokenEncoded);
console.log(usertoken);
} catch (exception) {
if (exception.code === 13003) {
} else {
console.log(exception);
}
}
}
我收到一条错误消息:
The identity API is not supported for this add-in. 13000
我相信这与我的清单文件有关,我没有发现任何问题。
我已将其放在文档的末尾。这是我使用过的代码。
<WebApplicationInfo>
<Id>97d836ee-5c77-4707-9d54-be09716fdxxx</Id>
<Resource>api://localhost:3000/97d836ee-5c77-4707-9d54-be09716fdxxx</Resource>
<Scopes>
<Scope>Files.Read.All</Scope>
<Scope>offline_access</Scope>
<Scope>openid</Scope>
<Scope>profile</Scope>
</Scopes>
</WebApplicationInfo>
</VersionOverrides>
</OfficeApp>
我看不出它有什么问题,但它不喜欢某些东西。有人能发现问题吗?
这是我的办公室客户
这是我的 XML 部分:
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_1">
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<FunctionFile resid="Commands.Url"/>
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgReadGroup">
<Label resid="GroupLabel"/>
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
<Control xsi:type="Button" id="ActionButton">
<Label resid="ActionButton.Label"/>
<Supertip>
<Title resid="ActionButton.Label"/>
<Description resid="ActionButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
<bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
<bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
</bt:LongStrings>
</Resources>
<WebApplicationInfo>
<Id>97d836ee-5c77-4707-9d54-be09716fxxxx</Id>
<Resource>api://localhost:3000/97d836ee-5c77-4707-9d54-be09716fxxxx</Resource>
<Scopes>
<Scope>Files.Read</Scope>
<Scope>openid</Scope>
<Scope>profile</Scope>
</Scopes>
</WebApplicationInfo>
</VersionOverrides>
</VersionOverrides>
</OfficeApp>
我还添加了此代码来检查我的客户是否具有 IdentityAPI 的要求集,并且它具有:
function IsIdentitySupported() {
if (Office.context.requirements.isSetSupported("IdentityAPI", "1.3")) {
console.log("Supported");
}
else {
// Provide alternate flow/logic.
}
}
刚刚将我的代码添加到 React 中的按钮,但它仍然返回:
顺便说一句 - 这在 Outlook 网页版上也失败了,并出现完全相同的错误。
当我使用 Yoman 创建另一个项目的脚手架,然后使用 configure-sso npm 命令时,我得到:
Error: Unable to set tenant reply urls.
ERROR: Bad Request({"error":{"code":"Request_BadRequest","message":"Invalid object identifier 'undefined'.","innerError":{"date":"2022-10-12T07:00:11","request-id":"972a0b4e-2691-4fe7-a8c6-1f247c2333f5","client-request-id":"972a0b4e-2691-4fe7-a8c6-1f247c2333f5"}}})
指定的 Outlook 版本应支持 Identity API 1.3 要求集。请参阅Outlook 客户端支持了解所有支持的版本。
您还可以在更新历史记录页面中找到您的 Outlook 版本。
尝试搭建一个新的加载项项目,然后使用
configure-sso
包将其配置为使用 SSO,如单点登录 (SSO) 快速入门中所述。
我遇到了类似的问题,我必须确保指定适当的 VersionOverides。在您的清单中,似乎版本 1.1 可能没有正确指定。尝试更新到以下内容:
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<FunctionFile resid="Commands.Url"/>
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgReadGroup">
<Label resid="GroupLabel"/>
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
<Control xsi:type="Button" id="ActionButton">
<Label resid="ActionButton.Label"/>
<Supertip>
<Title resid="ActionButton.Label"/>
<Description resid="ActionButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
<bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
<bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
</bt:LongStrings>
</Resources>
<WebApplicationInfo>
<Id>{Client_ID}</Id>
<Resource>api://localhost:3000/{Client_ID}</Resource>
<Scopes>
<Scope>Files.Read</Scope>
<Scope>openid</Scope>
<Scope>profile</Scope>
</Scopes>
</WebApplicationInfo>
</VersionOverrides>
</VersionOverrides>
</OfficeApp>
确保 WebApplicationInfo 是清单中 VersionOverrides 元素的子元素。这对我来说是个问题。
我仍然不知道到底是什么导致了这个问题,但我发现更改清单中 OfficeApp 部分下的以下属性突然导致它工作:
我怀疑最有可能修复的候选者是 Id、ProviderName 或 AppDomains。我唯一的猜测是,因为我复制了一个演示应用程序作为新应用程序的基础(但没有更改清单中的某些属性),所以令牌检索失败,因为令牌请求输入与缓存的输入略有不同。只是猜测...
最好的建议是确保在开发演示应用程序时更改所有这些值!