AcquireTokenForClient hangs

i am implementing a copy of the example found at How to use GraphClient for Microsoft Graph|Documentation.
i have my azure app registered, and the code copied into a sample web forms application.
when i call result = Await _app.AcquireTokenForClient(_scopes).ExecuteAsync(), the code hangs.

i previously had code written to use the PublicClientApplicationOptions examples i found here, but these only work with iis express, not iis once published to the server.
i modified my app registration to add the additional graph permissions listed in the document, but am not sure what is causing the call to get the token to hang.
one thing i am not sure of is the parameter client.ResourceId, this i am not setting.
any help is much appreciated.
thanks
Gavin

by moving the gettoken call routines into an async function, the routine no longer hangs and i am getting a token. BUT, my issue has now changed to Aspose.Email.AsposeBadServerResponceException: 'Server error Status: ErrorAccessDenied.
i created a new test application on the server, mirroring 100% the settings in the documentation.
i get the error when i call Dim folders = client.ListFolders()
Dim myToken = Await mytokenProvider.GetAccessTokenAsync()

    client.Resource = ResourceType.Users
    client.ResourceId = "gavin@accutitle.com"
    Dim folders = client.ListFolders()

Hello @gavinduffy,

I think you have specified an incorrect ResourceId. The resource ID is a unique identifier for a resource in Microsoft Graph. To find the Resource ID, do to user management menu blade on Azure Portal, click on the user needed in the list, go to a user page and copy Object ID field value. It will be a resource ID.
Please check.

hi Dmitry
thanks for the response.
i played with the resource id, it needs to be the email address of the user it seems.
my issue now is that i can send using a ConfidentialClientApplicationBuilder if the “app” is defined in azure as an application.
but my wish is to define as delegated and use a PublicClientApplicationBuilder which will popup a dialog to the client instead of requiring an admin to set up an app in azure. i cannot find any info on doing this since i am developing a webform and iis it seems does not allow this. if you have come across a scenario where this works, please share. any help is appreciated.

Hello @gavinduffy,

I don’t know exactly, since I haven’t experienced getting the token in a webform. But maybe you should look for code examples on Microsoft identity platform code samples page.