Share via

await graphClient.Me.Request().GetAsync() never returns

N. Mark Graves 6 Reputation points
2021-04-09T20:16:41.53+00:00

In the following code, the call to await graphClient.Me.Request().GetAsync(); never returns.

No exception is thrown. The App ID is registered with https://portal.azure.com/ for our tenant ID. The auth was originally some preview package, but I've since tried with Microsoft.Identity.Client and that doesn't work either.

protected async void GetMessages()
{
    try
    {
        var scopes = new string[] { 
                "User.Read", "Mail.Read", "email", "Mail.ReadWrite", "Mail.Send", "profile", "User.Read" 
            };

        // Build a client application.
        IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
                    .Create(MyRegisteredAppIDGUID)
                    .WithTenantId(OurTenantIDGUID)
                    .Build();

        // Create an authentication provider by passing in a client application and graph scopes.
        DeviceCodeProvider authProvider = new DeviceCodeProvider(publicClientApplication, scopes);

        // Create a new instance of GraphServiceClient with the authentication provider.
        var graphClient = new GraphServiceClient(authProvider);

        User me = await graphClient.Me.Request().GetAsync();

        ;
    }
    catch (Exception ex)
    {
    }
}
Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. JR 1 Reputation point
    2022-02-09T04:17:13.81+00:00

    Did you resolve this issue. I am also facing the same issue.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.