Eventi
17 mar, 23 - 21 mar, 23
Partecipa alla serie meetup per creare soluzioni di intelligenza artificiale scalabili basate su casi d'uso reali con altri sviluppatori ed esperti.
Iscriviti subitoQuesto browser non è più supportato.
Esegui l'aggiornamento a Microsoft Edge per sfruttare i vantaggi di funzionalità più recenti, aggiornamenti della sicurezza e supporto tecnico.
The Microsoft Graph client is designed to make it simple to make calls to Microsoft Graph. You can use a single client instance for the lifetime of the application. For information about how to add and install the Microsoft Graph client package into your project, see Install the SDK.
The following code examples show how to create an instance of a Microsoft Graph client with an authentication provider in the supported languages. The authentication provider handles acquiring access tokens for the application.
Many different authentication providers are available for each language and platform. The different authentication providers support different client scenarios. For details about which provider and options are appropriate for your scenario, see Choose an Authentication Provider.
The client ID is the app registration ID that is generated when you register your app in the Azure portal.
var scopes = new[] { "User.Read" };
// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "common";
// Value from app registration
var clientId = "YOUR_CLIENT_ID";
// using Azure.Identity;
var options = new DeviceCodeCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
ClientId = clientId,
TenantId = tenantId,
// Callback function that receives the user prompt
// Prompt contains the generated device code that user must
// enter during the auth process in the browser
DeviceCodeCallback = (code, cancellation) =>
{
Console.WriteLine(code.Message);
return Task.FromResult(0);
},
};
// https://learn.microsoft.com/dotnet/api/azure.identity.devicecodecredential
var deviceCodeCredential = new DeviceCodeCredential(options);
var graphClient = new GraphServiceClient(deviceCodeCredential, scopes);
Include
using
statements forAzure.Identity
andMicrosoft.Graph
to run this code.
Eventi
17 mar, 23 - 21 mar, 23
Partecipa alla serie meetup per creare soluzioni di intelligenza artificiale scalabili basate su casi d'uso reali con altri sviluppatori ed esperti.
Iscriviti subitoFormazione
Modulo
Creare applicazioni Web ASP.NET MVC con Microsoft Graph .NET SDK - Training
Informazioni sull'utilizzo di Microsoft Graph .NET SDK in un'applicazione Web ASP.NET MVC.
Documentazione
Choose a Microsoft Graph authentication provider - Microsoft Graph
Learn how to choose scenario-specific authentication providers for your application.
Make API calls using the Microsoft Graph SDKs - Microsoft Graph
Provides instructions for creating Microsoft Graph HTTP requests using the SDKs.
Customize the Microsoft Graph SDK service client - Microsoft Graph
Provides instructions on how to change the default behavior of the Microsoft Graph SDK service client.