Hi @-- --
The DelegateAuthenticationProvider
class has been deprecated in the latest versions of the Microsoft Graph SDK. Instead, you can use the new authentication approach using Azure.Identity.
Furthermore, even before Graph SDK V5.0, the DelegateAuthenticationProvider
class was not used to obtain the graph client for unattended access, it was a delegated class and the user had to participate in the login.
If you wish to create an unattended Graph client, please refer to the following code snippet:
using Microsoft.Graph;
using Azure.Identity;
// ...
private static async Task<GraphServiceClient> GetGraphApiClient()
{
var scopes = new[] { "https://graph.microsoft.com/.default" };
// Values from app registration
var clientId = "YOUR_CLIENT_ID";
var tenantId = "YOUR_TENANT_ID";
var clientSecret = "YOUR_CLIENT_SECRET";
// using Azure.Identity;
var options = new ClientSecretCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);
var graphServiceClient = new GraphServiceClient(clientSecretCredential, scopes);
return graphServiceClient;
}
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.