An API that connects multiple Microsoft services, enabling data access and automation across platforms
Hi @Kenta Matsunaga
The DelegateAuthenticationProvider class is no longer available in Microsoft.Graph version 5.0.0 or later. This is because the Graph SDK has changed the way it handles authentication and now uses the Azure.Identity package. https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/upgrade-to-v5.md#authentication
To fix this error, you need to use a different class that implements the IAccessTokenProvider interface from the Azure.Identity package, such as OnBehalfOfCredential. Then, you can pass this class to the GraphServiceClient constructor along with the scopes you need.
using Azure.Core;
using Azure.Identity;
using Microsoft.Graph;
string refreshToken = "...";
string[] scopes = new[] { "User.Read" };
var onBehalfOfCredential = new OnBehalfOfCredential(
tenantId: "your-tenant-id",
clientId: "your-client-id",
clientSecret: "your-client-secret",
userAssertionToken: refreshToken
);
var graphClient = new GraphServiceClient(onBehalfOfCredential, scopes);
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.