|
@@ -6,6 +6,7 @@ class OneDriveConfig {
|
|
|
private static instance: OneDriveConfig;
|
|
|
private clientId: string = '';
|
|
|
private sharepointUrl: string = '';
|
|
|
+ private sharepointTenantId: string = '';
|
|
|
private msalInstance: PublicClientApplication | null = null;
|
|
|
private currentAuthorityType: 'personal' | 'organizations' = 'personal';
|
|
|
|
|
@@ -39,7 +40,7 @@ class OneDriveConfig {
|
|
|
headers,
|
|
|
credentials: 'include'
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
if (!response.ok) {
|
|
|
throw new Error('Failed to fetch OneDrive credentials');
|
|
|
}
|
|
@@ -48,6 +49,7 @@ class OneDriveConfig {
|
|
|
|
|
|
const newClientId = config.onedrive?.client_id;
|
|
|
const newSharepointUrl = config.onedrive?.sharepoint_url;
|
|
|
+ const newSharepointTenantId = config.onedrive?.sharepoint_tenant_id;
|
|
|
|
|
|
if (!newClientId) {
|
|
|
throw new Error('OneDrive configuration is incomplete');
|
|
@@ -55,6 +57,7 @@ class OneDriveConfig {
|
|
|
|
|
|
this.clientId = newClientId;
|
|
|
this.sharepointUrl = newSharepointUrl;
|
|
|
+ this.sharepointTenantId = newSharepointTenantId;
|
|
|
}
|
|
|
|
|
|
public async getMsalInstance(
|
|
@@ -63,8 +66,9 @@ class OneDriveConfig {
|
|
|
await this.ensureInitialized(authorityType);
|
|
|
|
|
|
if (!this.msalInstance) {
|
|
|
- const authorityEndpoint =
|
|
|
- this.currentAuthorityType === 'organizations' ? 'common' : 'consumers';
|
|
|
+ const authorityEndpoint = this.currentAuthorityType === 'organizations'
|
|
|
+ ? (this.sharepointTenantId || 'common')
|
|
|
+ : 'consumers';
|
|
|
const msalParams = {
|
|
|
auth: {
|
|
|
authority: `https://login.microsoftonline.com/${authorityEndpoint}`,
|
|
@@ -89,6 +93,10 @@ class OneDriveConfig {
|
|
|
return this.sharepointUrl;
|
|
|
}
|
|
|
|
|
|
+ public getSharepointTenantId(): string {
|
|
|
+ return this.sharepointTenantId;
|
|
|
+ }
|
|
|
+
|
|
|
public getBaseUrl(): string {
|
|
|
if (this.currentAuthorityType === 'organizations') {
|
|
|
if (!this.sharepointUrl || this.sharepointUrl === '') {
|