@microsoft/mgt
Version:
The Microsoft Graph Toolkit
41 lines • 1.44 kB
JavaScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import { AuthenticationHandlerOptions } from '@microsoft/microsoft-graph-client';
/**
* returns a promise that resolves after specified time
* @param time in milliseconds
*/
export function getEmailFromGraphEntity(entity) {
const person = entity;
const user = entity;
const contact = entity;
if (user.mail) {
return user.mail;
}
else if (person.scoredEmailAddresses && person.scoredEmailAddresses.length) {
return person.scoredEmailAddresses[0].address;
}
else if (contact.emailAddresses && contact.emailAddresses.length) {
return contact.emailAddresses[0].address;
}
return null;
}
/**
* creates an AuthenticationHandlerOptions from scopes array that
* can be used in the Graph sdk middleware chain
*
* @export
* @param {...string[]} scopes
* @returns
*/
export function prepScopes(...scopes) {
const authProviderOptions = {
scopes
};
return [new AuthenticationHandlerOptions(undefined, authProviderOptions)];
}
//# sourceMappingURL=GraphHelpers.js.map