I am following the sample code provided in "Azure-Sample" to acquire token to call Microsoft Graph Api. But Resharper suggesting "Possible System.NullReferenceException" in await app.AcquireTokenForClient(scopes) .ExecuteAsync(); How to resolve NullReference exception?
Clone the code and seeing "Possible System.NullReferenceException"
AuthenticationResult result = null;
try
{
result = await app.AcquireTokenForClient(scopes)
.ExecuteAsync();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Token acquired");
Console.ResetColor();
}
catch (MsalServiceException ex) when (ex.Message.Contains("AADSTS70011"))
{
// Invalid scope. The scope has to be of the form "https://resourceurl/.default"
// Mitigation: change the scope to be as expected
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Scope provided is not supported");
Console.ResetColor();
}
Resharper is suggesting "Possible System.NullReferenceException", any idea how to resolve?
