1
1
user"
components:
schemas:
microsoft.graph.user:
type: object
properties:
id:
type: string
displayName:
type: string
You can then use the Kiota command line tool to generate the API client classes.
Bash
Copy
kiota generate -l csharp -d get-me.yml -c GetUserApiClient -n
GetUserClient.ApiClient -o ./Client
Register an application
To be able to authenticate with the Microsoft identity platform and get an access
token for Microsoft Graph, you need to create an application registration. You can
install the Microsoft Graph PowerShell SDK and use it to create the app
registration, or register the app manually in the Azure Active Directory admin
center.
The following instructions register an app and enable device code flow for
authentication.
Azure portal
PowerShell
Open a browser and navigate to the Azure Active Directory admin center. Sign in
with your Azure account.
Select Azure Active Directory in the left-hand navigation, then select App
registrations under Manage.
Select New registration. On the Register an application page, set the values as
follows.
Locate the Advanced settings section. Set the Allow public client flows toggle to
Yes, then select Save.
C#
Copy
using Azure.Identity;
using GetUserClient.ApiClient;
using Microsoft.Kiota.Authentication.Azure;
using Microsoft.Kiota.Bundle;
This example uses the DeviceCodeCredential class. You can use any of the credential
classes from the Azure.Identity library.
.NET CLI
Copy
dotnet run
See also
kiota-samples repository contains the code from this guide.
ToDoItem Sample API implements a sample OpenAPI in ASP.NET Core and sample clients
in multiple languages.