Google Calendar V3 hangs when used outside local environment

前端 未结 3 523
失恋的感觉
失恋的感觉 2021-01-26 07:46

I\'m working on a wrapper for the .net version of the Google Calendar API. The authentication is rather simple and working fine locally (localhost:port).

UserCr         


        
3条回答
  •  不知归路
    2021-01-26 08:26

    I suspect the problem is that you're using AuthorizeAsync(...).Result. Using the Result property blocks the current thread... and I suspect that ASP.NET is trying to schedule the continuation (when authentication completes) in the same thread, leading to a deadlock.

    Given that you're blocking anyway, is there any particular reason you want to use the AuthorizeAsync call? You'd normally use that in the context of an async method, where you'd have:

    var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(...);
    

    (Looking at GoogleWebAuthorizationBroker, I can't see a synchronous alternative at the moment, but that's what you should probably be looking for. My guess is that GoogleWebAuthorizationBroker isn't designed to be used in this situation.)

    Admittedly I don't know nearly as much as I probably should about either the ASP.NET synchronization context or the Google auth API, but hopefully explaining why there's a problem might be a good starting point... you probably want to read Stephen Cleary's article about synchronization contexts, too.

提交回复
热议问题