OneDrive/samples

FilePicker v8 with Sharepoint accounts

AlexMyU opened this issue · 5 comments

Hello,

I created an app that uses JS FilePicker v8. With personal accounts everything works as expected. But when I try to sign in to my work account (@.onmicrosoft.com), I get message "That Microsoft account doesn't exist. Enter a different account or [get a new one]".

If I replace the authority URL https://login.microsoftonline.com/consumers with https://login.microsoftonline.com/common, I can sign in both to my personal and work accounts.
But when I try to open a picker window with my personal account, I get error "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope 'onedrive.readwrite openid profile' is not configured for this tenant.".

How to make one JS FilePicker for all users both with personal or corporate accounts?

Thanks.

You can't target personal and business accounts within the same picker instance, meaning you can't browse files across two accounts at the same time.

When loading in business the base URLs need to reference the ODB/SharePoint paths, and for consumer they should point to the consumer paths. As well you'd need to request the right scopes OneDrive.ReadWrite doesn't exist for business drives, you can use Files.ReadWrite for both I believe.

You can't target personal and business accounts within the same picker instance, meaning you can't browse files across two accounts at the same time.

When loading in business the base URLs need to reference the ODB/SharePoint paths, and for consumer they should point to the consumer paths. As well you'd need to request the right scopes OneDrive.ReadWrite doesn't exist for business drives, you can use Files.ReadWrite for both I believe.

Hello Patrick,

Thank you for answering. But your answer is not relevant. I do not want to browse files across multiple accounts. I just test different types of accounts in different browsers.

Here is a text from https://devblogs.microsoft.com/microsoft365dev/onedrive-file-picker-v8-now-generally-available/
"The OneDrive File Picker lets you connect your custom web apps to content stored in OneDrive (both the commercial and business versions) and SharePoint."

I have a web app. It has many visitors. They store their files in cloud storages (Dropbox, Google Drive, OneDrive). And want to choose and share these files. This is why I use Picker.
Now, lets ignore Dropbox and Google user, and consider Microsoft users only. Some of them have personal accounts and others have SharePoint accounts. How should I configure OneDrive Picker so that both categories (with OneDrive accounts and SharePoint account) could use Picker for choosing files?

Thanks.

JCrew0 commented

Hey @AlexMyU can you elaborate on what you mean by "SharePoint Accounts" and "OneDrive Accounts"? OneDrive and SharePoint use the same Microsoft authentication.

Patrick was not referring to multiple accounts for the same user, he was referencing different login flows depending on if the user has a Microsoft account through their organization or has a personal Microsoft account.

Hey @JCrew0 ,

Can you please check my initial post? It describes what I want to achieve and what problems I faced.
I meant the following:

  • SharePoint Accounts - account that I got from my company (@.onmicrosoft.com)
  • OneDrive Accounts - my personal account (***@hotmail.com).

The goal is to have one Picker on a website and allow many different visitors to use it to select files from their accounts, regardless of account type.

JCrew0 commented

Hey @AlexMyU, I think Patrick's response should still stand. When you use the personal account, you should load the instance of the picker with consumer urls, whereas when you use the business account, you should load the instance of the ODB/SharePoint urls.

Essentially, you'll have to add logic to recognize which account-type is being used and load the picker accordingly.

While we used to have a JavaScript wrapper that would do that logic for you in v7.2, it's no longer possible in v8 given some new security protocols.

Hopefully that helps explain and let me know if you have any other questions!