diff --git a/api/src/app.service.ts b/api/src/app.service.ts index 927d7cc..975acd0 100644 --- a/api/src/app.service.ts +++ b/api/src/app.service.ts @@ -1,8 +1,27 @@ import { Injectable } from '@nestjs/common'; +import { MsGraphService, MsGraphClient } from '@noahspan/noahspan-modules'; +import { Person } from '@microsoft/microsoft-graph-types'; @Injectable() export class AppService { + constructor(private readonly msGraphService: MsGraphService) {} + getHello(): string { return 'Hello World!'; } + + async getPersonSearchResults(accessToken: string): Person[] { + const graphToken: string = await this.msGraphService.getMsGraphAuth( + accessToken, + ['user.read'] + ); + console.log(graphToken); + const client: MsGraphClient = + await this.msGraphService.getMsGraphClientDelegated(graphToken); + const results: any = await client.api(`me/people/?$search=${search}`).get(); + console.log(results); + const personResults: Person[] = results.values ? results.values : []; + + return personResults; + } }