|
10 | 10 | */ |
11 | 11 |
|
12 | 12 | import type { MSTeamsAccessTokenProvider } from "./attachments/types.js"; |
| 13 | +import { buildUserAgent } from "./user-agent.js"; |
13 | 14 |
|
14 | 15 | const GRAPH_ROOT = "https://graph.microsoft.com/v1.0"; |
15 | 16 | const GRAPH_BETA = "https://graph.microsoft.com/beta"; |
@@ -41,6 +42,7 @@ export async function uploadToOneDrive(params: { |
41 | 42 | const res = await fetchFn(`${GRAPH_ROOT}/me/drive/root:${uploadPath}:/content`, { |
42 | 43 | method: "PUT", |
43 | 44 | headers: { |
| 45 | + "User-Agent": buildUserAgent(), |
44 | 46 | Authorization: `Bearer ${token}`, |
45 | 47 | "Content-Type": params.contentType ?? "application/octet-stream", |
46 | 48 | }, |
@@ -90,6 +92,7 @@ export async function createSharingLink(params: { |
90 | 92 | const res = await fetchFn(`${GRAPH_ROOT}/me/drive/items/${params.itemId}/createLink`, { |
91 | 93 | method: "POST", |
92 | 94 | headers: { |
| 95 | + "User-Agent": buildUserAgent(), |
93 | 96 | Authorization: `Bearer ${token}`, |
94 | 97 | "Content-Type": "application/json", |
95 | 98 | }, |
@@ -186,6 +189,7 @@ export async function uploadToSharePoint(params: { |
186 | 189 | { |
187 | 190 | method: "PUT", |
188 | 191 | headers: { |
| 192 | + "User-Agent": buildUserAgent(), |
189 | 193 | Authorization: `Bearer ${token}`, |
190 | 194 | "Content-Type": params.contentType ?? "application/octet-stream", |
191 | 195 | }, |
@@ -251,7 +255,7 @@ export async function getDriveItemProperties(params: { |
251 | 255 |
|
252 | 256 | const res = await fetchFn( |
253 | 257 | `${GRAPH_ROOT}/sites/${params.siteId}/drive/items/${params.itemId}?$select=eTag,webDavUrl,name`, |
254 | | - { headers: { Authorization: `Bearer ${token}` } }, |
| 258 | + { headers: { "User-Agent": buildUserAgent(), Authorization: `Bearer ${token}` } }, |
255 | 259 | ); |
256 | 260 |
|
257 | 261 | if (!res.ok) { |
@@ -289,7 +293,7 @@ export async function getChatMembers(params: { |
289 | 293 | const token = await params.tokenProvider.getAccessToken(GRAPH_SCOPE); |
290 | 294 |
|
291 | 295 | const res = await fetchFn(`${GRAPH_ROOT}/chats/${params.chatId}/members`, { |
292 | | - headers: { Authorization: `Bearer ${token}` }, |
| 296 | + headers: { "User-Agent": buildUserAgent(), Authorization: `Bearer ${token}` }, |
293 | 297 | }); |
294 | 298 |
|
295 | 299 | if (!res.ok) { |
@@ -349,6 +353,7 @@ export async function createSharePointSharingLink(params: { |
349 | 353 | { |
350 | 354 | method: "POST", |
351 | 355 | headers: { |
| 356 | + "User-Agent": buildUserAgent(), |
352 | 357 | Authorization: `Bearer ${token}`, |
353 | 358 | "Content-Type": "application/json", |
354 | 359 | }, |
|
0 commit comments