Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit df0af98

Browse files
authored
Add headers support (#327)
1 parent 313c0dc commit df0af98

File tree

4 files changed

+65
-58
lines changed

4 files changed

+65
-58
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11+
- Added headers support via the `--headers` option.
1112

1213
### Changed
1314

src/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
using Microsoft.Kiota.Abstractions;
2929
using Microsoft.Kiota.Abstractions.Authentication;
3030
using Microsoft.Kiota.Cli.Commons.Extensions;
31+
using Microsoft.Kiota.Cli.Commons.Http;
32+
using Microsoft.Kiota.Cli.Commons.Http.Headers;
3133
using Microsoft.Kiota.Http.HttpClientLibrary;
3234
using Microsoft.Kiota.Serialization.Form;
3335
using Microsoft.Kiota.Serialization.Json;
@@ -58,7 +60,9 @@ static async Task<int> Main(string[] args)
5860
}
5961
adapter.BaseUrl = adapter.BaseUrl?.TrimEnd('/');
6062
return adapter;
61-
}).RegisterCommonServices();
63+
})
64+
.RegisterCommonServices()
65+
.RegisterHeadersOption(() => InMemoryHeadersStore.Instance);
6266
builder.AddMiddleware(async (ic, next) =>
6367
{
6468
var host = ic.GetHost();
@@ -152,7 +156,8 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
152156
GraphServiceLibraryClientVersion = $"{assemblyVersion?.Major ?? 0}.{assemblyVersion?.Minor ?? 0}.{assemblyVersion?.Build ?? 0}",
153157
GraphServiceTargetVersion = "1.0"
154158
};
155-
return GraphCliClientFactory.GetDefaultClient(options, loggingHandler: p.GetRequiredService<LoggingHandler>());
159+
var headersHandler = new NativeHttpHeadersHandler(() => InMemoryHeadersStore.Instance, p.GetService<ILogger<NativeHttpHeadersHandler>>());
160+
return GraphCliClientFactory.GetDefaultClient(options, loggingHandler: p.GetRequiredService<LoggingHandler>(), middlewares: new[] { headersHandler });
156161
});
157162
services.AddSingleton<IAuthenticationProvider>(p =>
158163
{

src/msgraph-cli.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ImplicitUsings>disable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
<AssemblyName>mgc</AssemblyName>
10-
<Version>1.0.0-preview.1</Version>
10+
<Version>1.0.0-preview.2</Version>
1111
</PropertyGroup>
1212

1313
<PropertyGroup>
@@ -57,7 +57,7 @@
5757
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
5858
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
5959
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
60-
<PackageReference Include="Microsoft.Graph.Cli.Core" Version="1.0.0-preview.3" />
60+
<PackageReference Include="Microsoft.Graph.Cli.Core" Version="1.0.0-preview.4" />
6161
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
6262
</ItemGroup>
6363

src/packages.lock.json

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141
},
4242
"Microsoft.Graph.Cli.Core": {
4343
"type": "Direct",
44-
"requested": "[1.0.0-preview.3, )",
45-
"resolved": "1.0.0-preview.3",
46-
"contentHash": "Rdw0oN/hS2FABQ+sAy256O88GLo0QFGa4cjDkLi5GSxU22YyNJRYmpcuFW3VKhpfMo646rssahNe5wBD3S0kyw==",
44+
"requested": "[1.0.0-preview.4, )",
45+
"resolved": "1.0.0-preview.4",
46+
"contentHash": "Pc+qnFG6qTNdlA3J/Ng0pKJz5WTUAKphqj/YWhfv9gRRxwdkil/wmSjg5uo2pZJozjNUFGlczOHnpK/RuqIgcg==",
4747
"dependencies": {
48-
"Azure.Identity": "1.10.0",
48+
"Azure.Identity": "1.9.0",
4949
"JmesPath.Net": "1.0.308",
5050
"Microsoft.Extensions.Hosting": "7.0.1",
5151
"Microsoft.Extensions.Http": "7.0.0",
52-
"Microsoft.Graph.Core": "3.0.10",
53-
"Microsoft.Kiota.Cli.Commons": "0.3.1-preview.1",
52+
"Microsoft.Graph.Core": "3.0.11",
53+
"Microsoft.Kiota.Cli.Commons": "0.4.1-preview.1",
5454
"Microsoft.Kiota.Http.HttpClientLibrary": "1.1.1",
5555
"Spectre.Console": "0.47.0",
5656
"System.CommandLine": "2.0.0-beta4.22272.1"
@@ -69,11 +69,11 @@
6969
},
7070
"Azure.Core": {
7171
"type": "Transitive",
72-
"resolved": "1.34.0",
73-
"contentHash": "6dNpM8OlGO+5gvt97tHXBp9qWRFkimRFulupDSGRgyT3sje1kQNza1/EMYaDcolmNARPmVJo8+wgD6ReV9wG5Q==",
72+
"resolved": "1.33.0",
73+
"contentHash": "p06/5ueyCwKe09zqz7bPR6vbWRGrDy6Ot4aqjrjnowhFlXUBoljUdH+abDZP2vUuSZrOSstF4h860hBHWh8uHg==",
7474
"dependencies": {
7575
"Microsoft.Bcl.AsyncInterfaces": "1.1.1",
76-
"System.Diagnostics.DiagnosticSource": "6.0.1",
76+
"System.Diagnostics.DiagnosticSource": "4.6.0",
7777
"System.Memory.Data": "1.0.2",
7878
"System.Numerics.Vectors": "4.5.0",
7979
"System.Text.Encodings.Web": "4.7.2",
@@ -83,12 +83,12 @@
8383
},
8484
"Azure.Identity": {
8585
"type": "Transitive",
86-
"resolved": "1.10.0",
87-
"contentHash": "j7HIhQ8Bnf2s325hNwjsTa7jXlJmWFSPgKJCrc1cv2XozEmFsjto1XaCnQzLmbPaTeL6CS5t26icTflY20BnHQ==",
86+
"resolved": "1.9.0",
87+
"contentHash": "VGcyxE66Za9mO0MtTYG1+ABZGF84QS+KZW8RTbcpYXLomHHvGT+aAL/Yg/ayfN+Usk2Z+DKB0+hymBaOAokj/w==",
8888
"dependencies": {
89-
"Azure.Core": "1.34.0",
90-
"Microsoft.Identity.Client": "4.54.1",
91-
"Microsoft.Identity.Client.Extensions.Msal": "2.31.0",
89+
"Azure.Core": "1.32.0",
90+
"Microsoft.Identity.Client": "4.49.1",
91+
"Microsoft.Identity.Client.Extensions.Msal": "2.25.3",
9292
"System.Memory": "4.5.4",
9393
"System.Security.Cryptography.ProtectedData": "4.7.0",
9494
"System.Text.Json": "4.7.2",
@@ -284,8 +284,8 @@
284284
},
285285
"Microsoft.Extensions.Logging.Abstractions": {
286286
"type": "Transitive",
287-
"resolved": "7.0.0",
288-
"contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw=="
287+
"resolved": "7.0.1",
288+
"contentHash": "pkeBFx0vqMW/A3aUVHh7MPu3WkBhaVlezhSZeb1c9XD0vUReYH1TLFSy5MxJgZfmz5LZzYoErMorlYZiwpOoNA=="
289289
},
290290
"Microsoft.Extensions.Logging.Configuration": {
291291
"type": "Transitive",
@@ -365,13 +365,13 @@
365365
},
366366
"Microsoft.Graph.Core": {
367367
"type": "Transitive",
368-
"resolved": "3.0.10",
369-
"contentHash": "TQQLEgM+mOn0M2MKf16dO/BvhH8iqOs+0DPiNupAGVxph4/X6EjJT8sseBUleitggMPJpyH6E0j64UI3YL9SQA==",
368+
"resolved": "3.0.11",
369+
"contentHash": "3+0dXYU6Ss+CXs4S0ga1RKUVTRHCkvpMRgPaKiAoVsY6BSYan2s/81gv3GPL/RoE6XU93sMxmWSlwH+6TsgTcQ==",
370370
"dependencies": {
371-
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "6.32.1",
371+
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "6.32.2",
372372
"Microsoft.Kiota.Abstractions": "1.3.1",
373373
"Microsoft.Kiota.Authentication.Azure": "1.0.3",
374-
"Microsoft.Kiota.Http.HttpClientLibrary": "1.0.6",
374+
"Microsoft.Kiota.Http.HttpClientLibrary": "1.1.1",
375375
"Microsoft.Kiota.Serialization.Form": "1.0.1",
376376
"Microsoft.Kiota.Serialization.Json": "1.0.8",
377377
"Microsoft.Kiota.Serialization.Multipart": "1.0.0",
@@ -382,71 +382,71 @@
382382
},
383383
"Microsoft.Identity.Client": {
384384
"type": "Transitive",
385-
"resolved": "4.54.1",
386-
"contentHash": "YkQkV3IRaA1W36HD4NRD1cq+QFr+4QPKK3SgTSpx+RiobXnLZ6E9anOjDi2TS7okOEofBbjR6GyTPp4IR0MnEQ==",
385+
"resolved": "4.49.1",
386+
"contentHash": "vDU3cdXIom4+pxJk8sDJcHYTHPhb6DSVF9zjFY61SoQVs1OxbHZY9+mBnq1gGkG7N/o04WTt42IdV/0gf1+5DA==",
387387
"dependencies": {
388388
"Microsoft.IdentityModel.Abstractions": "6.22.0"
389389
}
390390
},
391391
"Microsoft.Identity.Client.Extensions.Msal": {
392392
"type": "Transitive",
393-
"resolved": "2.31.0",
394-
"contentHash": "IhGSqN0szneKC5Qk3/okJQJbDpQfLW/+mvslhzJPox4t2UuIkA2ZHe4w/z62ASye46G9sQWF9qqLXTgNacE2xQ==",
393+
"resolved": "2.25.3",
394+
"contentHash": "I6/Od0d3OMD9b7RPxW1l25A8oA94H+r9ZtrOe4Ogk49Ftxhs9RS+pbzPE5dLe0i7nQy+1aob7mR22YsNcc0BiQ==",
395395
"dependencies": {
396-
"Microsoft.Identity.Client": "4.54.1",
396+
"Microsoft.Identity.Client": "4.49.1",
397397
"System.IO.FileSystem.AccessControl": "5.0.0",
398398
"System.Security.Cryptography.ProtectedData": "4.5.0"
399399
}
400400
},
401401
"Microsoft.IdentityModel.Abstractions": {
402402
"type": "Transitive",
403-
"resolved": "6.32.1",
404-
"contentHash": "S44xfpWeoPOQl2YHdp1TB0iYMXF0QHvHHFHsLere9j/0VL5/sTimy7KYjNI+46GXwOjRFvdtt+vIb36UjubEaA=="
403+
"resolved": "6.32.2",
404+
"contentHash": "Ul0qehKXMlq6+73l2w8/daStt8InzIzTzwt2fcMHGbe7pI5pBnwrLEwqALAxcnOkMy2wFY45kJn7QilaOdbkgw=="
405405
},
406406
"Microsoft.IdentityModel.JsonWebTokens": {
407407
"type": "Transitive",
408-
"resolved": "6.32.1",
409-
"contentHash": "mfEKYEyemkzkLfjxyN5/d1owLpE8JArslFNeDMlNMX75p+U9E67rg5MGzOXHhrOICfDS+OKV2ChJmPPZ9o4HIA==",
408+
"resolved": "6.32.2",
409+
"contentHash": "QfoQdEBDir4ShH3ub/hObgNCqoH3/5bhtyMshn6WhD/3PA7lKQyIEU5QpFUON/XeOcdYQqBmzqlgwTo27C9DgQ==",
410410
"dependencies": {
411-
"Microsoft.IdentityModel.Tokens": "6.32.1",
411+
"Microsoft.IdentityModel.Tokens": "6.32.2",
412412
"System.Text.Encoding": "4.3.0",
413413
"System.Text.Encodings.Web": "4.7.2",
414414
"System.Text.Json": "4.7.2"
415415
}
416416
},
417417
"Microsoft.IdentityModel.Logging": {
418418
"type": "Transitive",
419-
"resolved": "6.32.1",
420-
"contentHash": "g+VienLv1RjOfnxsDid3f6g5MTCRv/vDl3mofabc6m/uDzJpoAlXymo2kqpSAWMrGbqCQI01SvYDxHjmoo3h+Q==",
419+
"resolved": "6.32.2",
420+
"contentHash": "OgXpzJVBIQNdoyYCNgFprMZGrn2aAcU08w2oqyA2RvGrYvcVWsxJsygGcrMN0vDTvCwKUlpvjqT84eEktp3Avg==",
421421
"dependencies": {
422-
"Microsoft.IdentityModel.Abstractions": "6.32.1"
422+
"Microsoft.IdentityModel.Abstractions": "6.32.2"
423423
}
424424
},
425425
"Microsoft.IdentityModel.Protocols": {
426426
"type": "Transitive",
427-
"resolved": "6.32.1",
428-
"contentHash": "5zRyffBKOVw2y6McX7jSXmt8GUkdoKxkR5564C49xlDQEXUzh4P1IAL0G53b1BhfSzai7In93pnidyAjiVMQUQ==",
427+
"resolved": "6.32.2",
428+
"contentHash": "8OxIh/mraBLnyg/ezu/zbaQwv7p+2fSLdXlEb43hN3AWKNNIbWnXPrkbr2DmKfcUqFbL1vn+c2EKDzt/R7p8Hg==",
429429
"dependencies": {
430-
"Microsoft.IdentityModel.Logging": "6.32.1",
431-
"Microsoft.IdentityModel.Tokens": "6.32.1"
430+
"Microsoft.IdentityModel.Logging": "6.32.2",
431+
"Microsoft.IdentityModel.Tokens": "6.32.2"
432432
}
433433
},
434434
"Microsoft.IdentityModel.Protocols.OpenIdConnect": {
435435
"type": "Transitive",
436-
"resolved": "6.32.1",
437-
"contentHash": "/ZDC5DijpAheHVG6+X6Se68kuaMxD2Rkh8wW+yc26LStICQoLFwbYjnUTsi2Cw1h5TkD5oW1HYQkHf9SRkWBNw==",
436+
"resolved": "6.32.2",
437+
"contentHash": "qUuTzbB7JPGTK52TXeNxgUqxi62mmGT+xbUKTgeIVq+fE7Qj1kn+Ttkd76m7Ah2Y/VOecBlD4TK15vHFfVfjBg==",
438438
"dependencies": {
439-
"Microsoft.IdentityModel.Protocols": "6.32.1",
440-
"System.IdentityModel.Tokens.Jwt": "6.32.1"
439+
"Microsoft.IdentityModel.Protocols": "6.32.2",
440+
"System.IdentityModel.Tokens.Jwt": "6.32.2"
441441
}
442442
},
443443
"Microsoft.IdentityModel.Tokens": {
444444
"type": "Transitive",
445-
"resolved": "6.32.1",
446-
"contentHash": "8zGvRVWoVQSYg7qQj3zUslleZ/9lwDb6cWgDkIuqr0mCtXK/dr6IDgP7KpWJ5UhkoYYfLvwBl4GYEz4xMH524A==",
445+
"resolved": "6.32.2",
446+
"contentHash": "U4er/0UAY0AE8/Rzu9xHV1z95IqV3IbFZpqi2I4/042EBldb+s+E4lhZ3axuuioqg1mU1Ucr5Kq2EOCjf2JSgQ==",
447447
"dependencies": {
448448
"Microsoft.CSharp": "4.5.0",
449-
"Microsoft.IdentityModel.Logging": "6.32.1",
449+
"Microsoft.IdentityModel.Logging": "6.32.2",
450450
"System.Security.Cryptography.Cng": "4.5.0"
451451
}
452452
},
@@ -471,14 +471,15 @@
471471
},
472472
"Microsoft.Kiota.Cli.Commons": {
473473
"type": "Transitive",
474-
"resolved": "0.3.1-preview.1",
475-
"contentHash": "47eIQztHPuQPWJCscdqIcomC2SBLPUV+NsH1jR3yHzAgsVN+jE1FmnXgejgLY5ArSu7NLelC4bvpAr3Wc8Wywg==",
474+
"resolved": "0.4.1-preview.1",
475+
"contentHash": "/Fw7K2FheuqGGVgDCUVbmwXwSEeCMAkT0NClWxaw63j0rZsxIwC1NyFbdjdHiPg/OFqPT8i5mXvZhZFuTU1V2g==",
476476
"dependencies": {
477477
"JmesPath.Net": "1.0.308",
478-
"Microsoft.Kiota.Abstractions": "1.1.2",
478+
"Microsoft.Extensions.Logging.Abstractions": "7.0.1",
479+
"Microsoft.Kiota.Abstractions": "1.3.1",
479480
"Spectre.Console": "0.47.0",
480481
"System.CommandLine": "2.0.0-beta4.22272.1",
481-
"System.Text.Json": "7.0.2"
482+
"System.Text.Json": "7.0.3"
482483
}
483484
},
484485
"Microsoft.Kiota.Http.HttpClientLibrary": {
@@ -616,11 +617,11 @@
616617
},
617618
"System.IdentityModel.Tokens.Jwt": {
618619
"type": "Transitive",
619-
"resolved": "6.32.1",
620-
"contentHash": "m6kuL4jfpDHuWkUNS5peyO71nRH8nE2TsTC/n0Isajze4d86xTUmEJ3J0vzYdp4X3OQ72y9KXnQGtxgu9Axd0w==",
620+
"resolved": "6.32.2",
621+
"contentHash": "rChCYKLnmKLO8xFcLmOYSJh4lJXV1XkyddblRK5H3C3KDC/oYMMesU6oHd5CjvlqH1L5umtil1FQKYZG4/qDfQ==",
621622
"dependencies": {
622-
"Microsoft.IdentityModel.JsonWebTokens": "6.32.1",
623-
"Microsoft.IdentityModel.Tokens": "6.32.1"
623+
"Microsoft.IdentityModel.JsonWebTokens": "6.32.2",
624+
"Microsoft.IdentityModel.Tokens": "6.32.2"
624625
}
625626
},
626627
"System.IO": {
@@ -784,8 +785,8 @@
784785
},
785786
"System.Text.Json": {
786787
"type": "Transitive",
787-
"resolved": "7.0.2",
788-
"contentHash": "/LZf/JrGyilojqwpaywb+sSz8Tew7ij4K/Sk+UW8AKfAK7KRhR6mKpKtTm06cYA7bCpGTWfYksIW+mVsdxPegQ==",
788+
"resolved": "7.0.3",
789+
"contentHash": "AyjhwXN1zTFeIibHimfJn6eAsZ7rTBib79JQpzg8WAuR/HKDu9JGNHTuu3nbbXQ/bgI+U4z6HtZmCHNXB1QXrQ==",
789790
"dependencies": {
790791
"System.Text.Encodings.Web": "7.0.0"
791792
}

0 commit comments

Comments
 (0)