DelegateAuthenticationProvider no longer exists in the Microsoft Graph .NET SDK
The type or namespace name 'DelegateAuthenticationProvider' could not be foundShort answer
Microsoft Graph .NET SDK v5 removed DelegateAuthenticationProvider. Pass an Azure.Identity TokenCredential to the GraphServiceClient constructor instead. If you already hold an access token or need a custom flow, implement the Kiota IAccessTokenProvider interface and wrap it in a BaseBearerTokenAuthenticationProvider.
Fix it fast
1Find out which cause you have
Check which Microsoft.Graph version the project resolves. Version 5 or later is the one without the class.
dotnet list package | grep -i microsoft.graph2Match what you see, then jump to its fix
- 1
The compiler error appears right after a Microsoft.Graph package upgradeThe project moved to v5, which authenticates with Azure.Identity credentialsFix - 2
Old code returned a token string inside the delegateYou already have an access token, or your sign-in flow is customFix - 3
Requests reach Graph but arrive with no Authorization headerYou pass your own HttpClient, and it carries no authenticationFix
- 1
What does the error look like?
The type or namespace name 'DelegateAuthenticationProvider' could not be found
Cause 1 of 3
The project moved to v5, which authenticates with Azure.Identity credentials
1Check
The v5 upgrade guide says the GraphServiceClient constructor accepts a TokenCredential from Azure.Identity, in place of DelegateAuthenticationProvider.
dotnet list package | grep -i -E "microsoft.graph|azure.identity"2Fix
Add Azure.Identity, create the credential that matches your app type, and pass it with the scopes. A daemon app uses a client secret credential and the .default scope.
dotnet add package Azure.Identity
// C#
var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
var graphClient = new GraphServiceClient(credential, new[] { "https://graph.microsoft.com/.default" });3Verify
Build the project and call one simple endpoint.
dotnet build
// C#
var me = await graphClient.Users.GetAsync();Confirmed by learn.microsoft.com
Cause 2 of 3
You already have an access token, or your sign-in flow is custom
1Check
The v5 guide says custom flows are done by implementing the Kiota IAccessTokenProvider interface, which returns a token for a given URI.
grep -rn "DelegateAuthenticationProvider" --include=*.cs .2Fix
Write a small IAccessTokenProvider that returns your token, wrap it in BaseBearerTokenAuthenticationProvider and hand that to GraphServiceClient.
// C#
var authProvider = new BaseBearerTokenAuthenticationProvider(new TokenProvider());
var graphClient = new GraphServiceClient(authProvider);3Verify
The first call returns data instead of a 401.
// C#
var me = await graphClient.Me.GetAsync();Confirmed by github.com
Cause 3 of 3
You pass your own HttpClient, and it carries no authentication
1Check
The guide states that authentication is no longer handled in the HttpClient middleware pipeline, so a custom HttpClient must already handle it.
grep -rn "new GraphServiceClient(" --include=*.cs .2Fix
Give the client an authentication provider as the second constructor argument along with the HttpClient.
// C#
var graphClient = new GraphServiceClient(httpClient, authenticationProvider);3Verify
Requests now carry a bearer token and Graph returns data.
// C#
var me = await graphClient.Me.GetAsync();Confirmed by github.com
How do I stop it coming back?
- Read the upgrade guide before raising a major version of the Graph SDK.
- Keep client secrets in a secret store, not in the source.
- Use the credential type that matches the app: client credentials for daemons, authorization code or on-behalf-of for user flows.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Security
A Microsoft Entra access token shows Invalid Signature when you check it yourself
Tokens that a Microsoft API receives might not always be a JWT that can be decoded
A token issued for Microsoft Graph is not meant for you to validate, so a failed signature check is expected.
2 causes, each with a fixSecurity
Azure Databricks REST API returns 403 with a Microsoft Entra token
Error 403 User not authorized when calling the Azure Databricks API
A 403 means the token was accepted but the identity in it is not allowed in that workspace.
4 causes, each with a fixSecurity
ASP.NET Core cannot create the JWT because the signing key is too short or unusable
IDX10630: The '<key type>' for signing cannot be smaller than '<bits>' bits. KeySize: '<bits>'.
The error happens while the API signs the token, not while it checks one.
3 causes, each with a fixSecurity
.NET cannot convert the string to a JwtSecurityToken
SecurityTokenMalformedException
The handler only accepts a compact JWT: three dot-separated base64url segments for a signed token.
3 causes, each with a fixSecurity
AuthenticationException: your certificate validation callback returned false
System.Security.Authentication.AuthenticationException
This message means a validation callback was installed, yours or one a library added, and it returned false.
3 causes, each with a fixSecurity
A valid JWT fails to decode because its segments are base64url, not base64
Convert.FromBase64String throws FormatException on a JWT segment
A JWT is three base64url segments joined by dots, and a standard base64 decoder refuses all three differences: base64url uses - and _ instead of + and /, leaves off the = padding, and the dots are not part of any base64 alphabet.
3 causes, each with a fix