|
1 | 1 | # Microsoft Graph CLI |
2 | 2 |
|
| 3 | +## Required tools |
| 4 | +A commandline tool should work on any terminal. We recommend: |
| 5 | +- [Windows Terminal + version](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us) |
| 6 | +- MacOS terminal |
| 7 | +- PowerShell version 7.3.2 |
| 8 | + |
| 9 | +## Target project requirements |
| 10 | +Download the CLI SDK to get started for |
| 11 | +Windows, Mac, or Linux here on the assets link of the latest release: [CLI SDK Download](https://github.com/microsoftgraph/msgraph-cli/releases) |
| 12 | + |
| 13 | + |
| 14 | +## Registering an application in Azure AD |
| 15 | + |
| 16 | +## Creating an application registration |
| 17 | + |
| 18 | +> **Note:** this step is required if your client will be calling APIs that are protected by the Microsoft Identity Platform like Microsoft Graph. |
| 19 | +
|
| 20 | +Follow the instructions in [Register an application for Microsoft identity platform authentication](register-app.md) to get an application ID (also know as a client ID). |
| 21 | + |
| 22 | +## Creating the client application |
| 23 | + |
| 24 | +Replace `YOUR_CLIENT_ID` with the client ID from your app registration. |
| 25 | + |
| 26 | + |
| 27 | +## Authenticating on the CLI tool |
| 28 | + |
| 29 | +``` bash |
| 30 | +mgc login --client-id `YOUR_CLIENT_ID` --tenant-id `YOUR_TENANT_ID` --scopes User.ReadWrite --scopes Mail.ReadWrite |
| 31 | +``` |
| 32 | + |
| 33 | +## Executing the application |
| 34 | +Navigate to your download folder and use the **mgc** command to run commands on the CLI SDK. |
| 35 | +Add -h to your commands to view additional commands. |
| 36 | + |
| 37 | + |
| 38 | +### Authentication |
| 39 | +The SDK supports both delegeted and app-only authentication strategies. Run the command below to see supported authentication strategies. |
| 40 | + |
| 41 | +``` bash |
| 42 | +#View supported authentication strategies. Default is Device Code |
| 43 | +mgc login --help |
| 44 | +``` |
| 45 | + |
| 46 | +#### **Delegated access** |
| 47 | +**1. DeviceCode authentication strategy** |
| 48 | + |
| 49 | + |
| 50 | +``` bash |
| 51 | +#Using the Default authentication (which is Device Code) |
| 52 | +mgc login |
| 53 | +``` |
| 54 | +OR |
| 55 | + |
| 56 | +``` bash |
| 57 | +#Using the DeviceCode authentication explicitly |
| 58 | +mgc login --strategy DeviceCode |
| 59 | +``` |
| 60 | + |
| 61 | +**2.Interactive Browser authentication strategy** |
| 62 | +``` bash |
| 63 | +# Using interactive Browser authentication. |
| 64 | +mgc login --strategy InteractiveBrowser |
| 65 | + |
| 66 | +``` |
| 67 | + |
| 68 | +#### **App-only access** |
| 69 | +**1. Client Certificate authentication strategy** |
| 70 | +``` bash |
| 71 | +# Using Client Certificate authentication. |
| 72 | +mgc login --strategy ClientCertificate |
| 73 | + |
| 74 | +``` |
| 75 | +### Samples |
| 76 | +You can find additional samples here: [CLI SDK samples](https://github.com/microsoftgraph/msgraph-cli/tree/main/samples) |
| 77 | + |
| 78 | + |
3 | 79 | > Note: This repository is for the .NET CLI. If you are looking for the Python CLI, it's been moved to the [msgraph-cli-archived](https://github.com/microsoftgraph/msgraph-cli-archived) repository |
0 commit comments