简体   繁体   中英

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

https://login.microsoftonline.com/common

to

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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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