Skip to content

Commit

Permalink
Microsoft Outlook service root endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-blacklist committed Feb 23, 2025
1 parent 073b05b commit a763241
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ const scopes = [
'MailboxSettings.Read',
];

const enum EndpointNames {
Global = 'Microsoft Graph global service',
GovCloud = 'Microsoft Graph for US Government L4',
DoDCloud = 'Microsoft Graph for US Government L5 (DOD)',
China = 'Microsoft Graph China operated by 21Vianet',
}

const endpoints: Record<EndpointNames, string> = {
[EndpointNames.Global]: 'https://graph.microsoft.com',
[EndpointNames.GovCloud]: 'https://graph.microsoft.us',
[EndpointNames.DoDCloud]: 'https://dod-graph.microsoft.us',
[EndpointNames.China]: 'https://microsoftgraph.chinacloudapi.cn',
};

export class MicrosoftOutlookOAuth2Api implements ICredentialType {
name = 'microsoftOutlookOAuth2Api';

Expand Down Expand Up @@ -50,5 +64,16 @@ export class MicrosoftOutlookOAuth2Api implements ICredentialType {
},
},
},
{
displayName: 'Endpoint',
description: 'The service root endpoint to use when connecting to the Outlook API.',
name: 'graphEndpoint',
type: 'options',
default: endpoints[EndpointNames.Global],
options: Object.keys(endpoints).map((name) => ({
name,
value: endpoints[name as EndpointNames],
})),
},
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export async function microsoftApiRequest(
) {
const credentials = await this.getCredentials('microsoftOutlookOAuth2Api');

let apiUrl = `https://graph.microsoft.com/v1.0/me${resource}`;
let apiUrl = `${credentials.graphEndpoint}/v1.0/me${resource}`;
// If accessing shared mailbox
if (credentials.useShared && credentials.userPrincipalName) {
apiUrl = `https://graph.microsoft.com/v1.0/users/${credentials.userPrincipalName}${resource}`;
apiUrl = `${credentials.graphEndpoint}/v1.0/users/${credentials.userPrincipalName}${resource}`;
}

const options: IRequestOptions = {
Expand Down

0 comments on commit a763241

Please sign in to comment.