使用 JSOM 从 Sharepoint 托管应用程序读取 Sharepoint 在线用户配置文件

Read Sharepoint online UserProfiles from sharepoint hosted app using JSOM

我正在尝试通过参考以下 MSDN

从 sharepoint hostedapp 获取 sharepointonline 用户配置文件

https://dev.office.com/sharepoint/docs/general-development/how-to-retrieve-user-profile-properties-by-using-the-javascript-object-model-in

但是当我尝试执行代码时,它会抛出以下错误 "Error: Access denied. You do not have permission to perform this action or access this resource"。

在上面的文章中他们提到了进入 "domainName\userName",这里只是不知道我应该给哪个域我的应用程序域或我的 sharepointonline 域。

因为我尝试了两个域,但问题仍然存在。

请大家指教...

提前致谢

您的访问被拒绝,因为您的托管应用程序没有执行用户配置文件所需的权限。

在您的 SharePoint 托管应用程序解决方案上 AppManifest.xml 授予您的应用程序访问所需的权限。在您的情况下,它将是:

根据您的使用情况,您可能需要授予它的不仅仅是 "Read"。