Microsoft Graph - Issues when trying to upgrade from 3.19.0 to v5.56.0

Terry Fedirko 0 Reputation points

I got a problem when trying to upgrade GraphServiceClient from 3.19.0 to 5.56.0 (as shown below), how do I update this code to Microsoft.Graph 5.56? Please note, I find all examples on the web and they don't show me a solution:

   protected GraphServiceClient graphServiceClient




           GraphServiceClient gsc = new GraphServiceClient(

               new DelegateAuthenticationProvider(

                   (requestMessage) =>


                       requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", GetUserToken().GetAwaiter().GetResult());

                       return Task.FromResult(0);


           return gsc;



   protected async Task<string> GetUserToken()


       string signedInUserID = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

       string tenantID = ClaimsPrincipal.Current.FindFirst("").Value;

       string userObjectID = ClaimsPrincipal.Current.FindFirst("").Value;

       // get a token for the Graph without triggering any user interaction (from the cache, via multi-resource refresh token, etc)

       Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential clientCredentials =

           new Microsoft.IdentityModel.Clients.ActiveDirectory

               .ClientCredential(Config.ADSettings.EquiTrakAppId, Config.ADSettings.EquiTrakClientSecret);

       // initialize AuthenticationContext with the token cache of the currently signed in user, as kept in the app's database

       AuthenticationContext authenticationContext =

           new AuthenticationContext(Config.AzureADInstance + tenantID, new ADALTokenCache(signedInUserID));

       Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult authenticationResult =

           await authenticationContext

               .AcquireTokenSilentAsync(Config.GraphResourceId, clientCredentials, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));

       return authenticationResult.AccessToken;

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,317 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,603 questions
{count} votes