# Microsoft.Graph

**Kind:** Service

**Source:** `Pams/API/Pams.API.Core/Pams.API.Core.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.Graph` is a NuGet package dependency referenced by `Pams.API.Core`. It enables core API code to create authenticated Microsoft Graph requests and map responses from Microsoft Graph endpoints into application workflows.

## Diagram

```mermaid
sequenceDiagram
    participant Caller
    participant Core as Pams.API.Core
    participant Graph as Microsoft.Graph
    participant Api as Microsoft Graph API

    Caller->>Core: Request directory data
    Core->>Graph: Create authenticated request
    Graph->>Api: Send API request
    Api-->>Graph: Return response
    Graph-->>Core: Map response data
    Core-->>Caller: Return application result
```

## Usage

```ts
import { Client } from "@microsoft/microsoft-graph-client";

async function getCurrentUser(accessToken: string) {
  const client = Client.init({
    authProvider: (done) => done(null, accessToken),
  });

  return client
    .api("/me")
    .select("displayName,mail,userPrincipalName")
    .get();
}

const user = await getCurrentUser(process.env.GRAPH_ACCESS_TOKEN!);

console.log(user.displayName);
```

## AI Coding Instructions

- Keep Microsoft Graph request logic behind `Pams.API.Core` services or adapters rather than exposing SDK types to callers.
- Supply access tokens through the configured authentication flow; do not place tokens or client secrets in source code.
- Request only the Graph fields needed by the calling workflow with `$select` or the SDK equivalent.
- Handle Graph API failures, permission errors, and missing response properties before returning data to application code.
- Keep Microsoft Graph package updates aligned with the project’s NuGet dependency configuration.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.API.Core` — `Pams/API/Pams.API.Core/Pams.API.Core.csproj`:1
