简体   繁体   English

OneDrive SDK:如何使用单租户应用程序访问 onedrive 文件?

[英]OneDrive SDK : how can I use single tenant app to access onedrive files?

AADSTS50194: Application 'censured'(-app) is not configured as a multi-tenant application. Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant.

How can I use single-tenant specific endpoint?如何使用单租户特定端点? I want to create a file picker that permit user to browse its file and organization files.我想创建一个允许用户浏览其文件和组织文件的文件选择器。 I already read this question but, without editing OneDrive.js (library), I can't change我已经阅读了这个问题,但是如果不编辑 OneDrive.js(库),我无法更改

https://login.microsoftonline.com/common https://login.microsoftonline.com/common

to

https://login.microsoftonline.com/MY_TENANT_NAME https://login.microsoftonline.com/MY_TENANT_NAME

Hope you can help me, thanks.希望你能帮助我,谢谢。

because the onedrive.js library has the common endpoint hard coded, your easiest way is to change it to point to your tenant login endpoint.因为 onedrive.js 库具有硬编码的公共端点,您最简单的方法是将其更改为指向您的租户登录端点。

if you don't want to do that, have the user login before using the picker, then save the access token and endpoint and provide it to the js similar to whats being done here: https://github.com/OneDrive/onedrive-explorer-js/blob/master/index.html如果您不想这样做,请在使用选择器之前让用户登录,然后保存访问令牌和端点并将其提供给 js,类似于此处所做的操作: https://github.com/OneDrive/onedrive -explorer-js/blob/master/index.html

as per https://docs.microsoft.com/en-us/onedrive/developer/controls/file-pickers/js-v72/open-file?view=odsp-graph-online#advanced-options the advanced options of the picker gives you options to specify the endpointhint and accesstoken.根据https://docs.microsoft.com/en-us/onedrive/developer/controls/file-pickers/js-v72/open-file?view=odsp-graph-online#advanced-options的高级选项选择器为您提供指定端点提示和访问令牌的选项。

hope that helps,希望有帮助,

Update I just tried it this way and it seems to work.更新我刚刚尝试过这种方式,它似乎有效。 but I didn't try to do it with a token.但我没有尝试用令牌来做。 just an endpointHint, when I used an endpointHint, it didn't give me the error about the multi-tenant issue.只是一个端点提示,当我使用端点提示时,它没有给我关于多租户问题的错误。

<html>
<head>
<script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js"></script>
<script type="text/javascript">
  function launchOneDrivePicker(){
    var odOptions = {   
clientId: "myappid-guid-thing",
  action: "query",
  multiSelect: true,
  advanced: {endpointHint: "https://azuretenant-my.sharepoint.com/",},
  };
    OneDrive.open(odOptions);
  }
</script>
</head>
<body>
<button onClick="launchOneDrivePicker()">Open from OneDrive</button>
</body>
</html>

Please make sure you get the endpoint url right, eg, https://tenantname-my.sharepoint.com notice the "-my" after your tenant name, that's necessary. Please make sure you get the endpoint url right, eg, https://tenantname-my.sharepoint.com notice the "-my" after your tenant name, that's necessary.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM