1,066 questions
Identity API is not supported for this add-in
Ed Neary
20
Reputation points
We are creating an add-in that needs to retrieve the user's M365 email - the add-in is a taskpane and made for Word and Excel. The issue occurs when getting the access token prior to calling the graph api.
Office.onReady(async () => {
try {
// fails here
const accessToken = await OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: true });
const user = await getUserDetails(accessToken);
document.getElementById("userInfo").innerText =
`Name: ${user.displayName}\nEmail: ${user.mail || user.userPrincipalName}`;
}
catch (error) {
console.error("Error:", error);
}
});
The error is:
{name: 'API Not Supported', message: 'The identity API is not supported for this add-in.', code: 13000}
The add-in manifest is:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
xsi:type="TaskPaneApp">
<Id>AABBCCDD-AAAA-2222-1111-999999111111</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso7</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Edstest2228"/>
<Description DefaultValue="Fetch and display user name/email from Microsoft Graph."/>
<IconUrl DefaultValue="https://localhost/Icons/AddInTaskpane_Button_Icon.png"/>
<SupportUrl DefaultValue="https://localhost"/>
<Hosts>
<Host Name="Document" />
</Hosts>
<Requirements>
<Sets DefaultMinVersion="1.1">
<Set Name="SharedRuntime"/>
</Sets>
</Requirements>
<DefaultSettings>
<SourceLocation DefaultValue="https://localhost/simple.html"/>
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
<VersionOverrides Version="1.0">
<Hosts>
<Host xsi:type="Word">
<DesktopFormFactor>
<FunctionFile resid="taskpaneUrl"/>
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<CustomTab id="Tab1">
<Group id="Group1">
<Label resid="groupLabel"/>
<Control xsi:type="Button" id="ShowTaskpane">
<Label resid="buttonLabel"/>
<Supertip>
<Title resid="buttonTitle"/>
<Description resid="buttonDesc"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16"/>
<bt:Image size="32" resid="icon32"/>
<bt:Image size="80" resid="icon80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="taskpaneUrl"/>
</Action>
</Control>
</Group>
</CustomTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="icon16" DefaultValue="https://localhost/Icons/AddInTaskpane_Button_Icon.png"/>
<bt:Image id="icon32" DefaultValue="https://localhost/Icons/AddInTaskpane_Button_Icon.png"/>
<bt:Image id="icon80" DefaultValue="https://localhost/Icons/AddInTaskpane_Button_Icon.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="taskpaneUrl" DefaultValue="https://localhost/simple.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="groupLabel" DefaultValue="User Info2"/>
<bt:String id="buttonLabel" DefaultValue="Get User Info"/>
<bt:String id="buttonTitle" DefaultValue="Get Info2"/>
<bt:String id="buttonDesc" DefaultValue="Get the signed-in user's name and email."/>
</bt:ShortStrings>
</Resources>
<WebApplicationInfo>
<Id>19ff57b6-a68d-46fe-8358-77c42064a174</Id>
<Resource>https://graph.microsoft.com</Resource>
<Scopes>
<Scope>openid</Scope>
<Scope>profile</Scope>
<Scope>email</Scope>
<Scope>User.Read</Scope>
</Scopes>
</WebApplicationInfo>
</VersionOverrides>
</OfficeApp>
The html and javascript for the add-in is hosted locally:
https://localhost/simple.html
Here are the details for the Azure application:
Microsoft 365 and Office Development Office JavaScript API
Sign in to answer