AcquireTokenForClient(ewsScopes).ExecuteAsync() "Request to the endpoint timed out" in IIS

Viewed 321

I have a Webforms (ASP.Net) application which is trying to get a accesstoken from office365.

  • I succesfully get the token running the Website in IIS Express in Visual Studio (2019).
  • Running the website in IIS, i get the error "Request to the endpoint timed out".

Please, can anybody help?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim cca = ConfidentialClientApplicationBuilder.
            Create("000000-0000-0000").
            WithClientSecret("xxxxxxxxxxxxx").
            WithTenantId("00000-0000-0000").
            Build()

    Dim ewsScopes() As String = {"https://outlook.office365.com/.default"}
    Dim rc As String = cca.AcquireTokenForClient(ewsScopes).ExecuteAsync().GetAwaiter().GetResult().AccessToken
    Page.Response.Write(rc)
End Sub
2 Answers

You can try to increase request time in the web.config.

<system.web>
  <httpRuntime executionTimeout="180" />
</system.web>

I think, and this was the problem on my side, you need a Proxy Configuration.

This solution helps me and now it runs on iisexpress (vs2019) and as hosted in iis: Proxy Configuration for C# GraphSdk

Related