Base URL used for Multi Tenants

Copper Contributor

Hello,

I want users to select files from their personal and company drive but it requires a base url which is used to authenticate the user into the drive but the code examples and the docs don't have any indication of where to get a dynamic base url or the base url to use for the multiple tenants. 

 

Right now it only works for users in my organisation but I need it for users.

 

Edit: I am using the v8 file picker

 

Thank you

3 Replies

@OreSpurt 

It sounds like you are trying to use the Microsoft OneDrive for Business API to allow users to select files from their personal and company drives.

To authenticate users from multiple tenants, you will need to use the OAuth 2.0 protocol and obtain authorization credentials for each user.

The base URL for the OAuth 2.0 server is https://login.microsoftonline.com/common/oauth2/v2.0/authorize.

You can use this URL to redirect users to the Microsoft authorization server where they can grant your application access to their OneDrive data.

Once the user has granted access, you will receive an authorization code that you can exchange for an access token and a refresh token.

You can then use the access token to make authorized API requests on behalf of the user.

For more information on how to implement OAuth 2.0 for multiple tenants with OneDrive for Business, please refer to the Microsoft Graph documentation.

 

I hope this helps!

It's been a while since this was posted but you may have a simple problem to solve. Change your msalConfig to include common to support multitenant. Something like this:

const msalConfig = {
auth: {
// 'Application (client) ID' of app registration in Azure portal - this value is a GUID
clientId: "b9c6e65c-cbf5-4ffb-998f-6b1114440a93",
// Full directory URL, multi-tenant application. (MUST be /common)
authority: "https://login.microsoftonline.com/common",
// Full redirect URL
redirectUri: your_server_name, // <--- same as in the app registration in azure.
},

I am facing the same issue. I am integrating the file picker in my website for multi tenants app but don't have generic baseUrl for picker. Sample code given by Microsoft has suggested to use hard coded value for baseUrl for testing which will work for single tenant app but no mention of how to replace this for multi tenant app. Documentation and Sample code . (Note: I have already changed my msalConfig as suggested by mgouker). And For personal account baseUrl - https://onedrive.live.com/picker is not working 

const url = combine(
baseUrl,
`/_layouts/15/FilePicker.aspx?${queryString}`
);