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

Commit f881cde

Browse files
committed
Initialize commands from generated code.
1 parent 2d9704e commit f881cde

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
"program": "${workspaceFolder}/src/bin/Debug/net6.0/msgraph-cli.dll",
13-
"args": [],
13+
"args": ["-h"],
1414
"cwd": "${workspaceFolder}",
1515
"console": "internalConsole",
1616
"stopAtEntry": false

src/Program.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
using System.CommandLine;
1+
using ApiSdk;
2+
using Azure.Identity;
3+
using Microsoft.Graph.Cli.Utils;
4+
using Microsoft.Kiota.Authentication.Azure;
5+
using Microsoft.Kiota.Http.HttpClientLibrary;
6+
using System.CommandLine;
27
using System.Threading.Tasks;
38

49
namespace Microsoft.Graph.Cli
510
{
611
class Program {
712
static async Task<int> Main(string[] args) {
8-
var rootCommand = new RootCommand(); // TODO: Replace with root command from generated client
13+
DeviceCodeCredentialOptions credOptions = new()
14+
{
15+
ClientId = Constants.ClientId,
16+
TenantId = Constants.TenantId
17+
};
18+
19+
var credential = new DeviceCodeCredential(credOptions);
20+
var authProvider = new AzureIdentityAuthenticationProvider(credential);
21+
var core = new HttpClientRequestAdapter(authProvider);
22+
var client = new GraphClient(core);
23+
24+
var rootCommand = client.BuildCommand();
925
rootCommand.Description = "Microsoft Graph CLI";
1026
return await rootCommand.InvokeAsync(args);
1127
}

src/msgraph-cli.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="Azure.Identity" Version="1.5.0" />
1213
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.25" />
14+
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.0.6" />
1315
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.0.16" />
1416
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.0.6" />
1517
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />

src/utils/Constants.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Microsoft.Graph.Cli.Utils
2+
{
3+
class Constants
4+
{
5+
public const string AuthRecordPath = "authRecord";
6+
7+
public const string ClientId = "f645f5f8-2332-496d-9d85-e714b1192f0c";
8+
9+
public const string TenantId = "39aafea4-2975-4790-9c07-e616c1c35d99";
10+
}
11+
}

0 commit comments

Comments
 (0)