ASP.NET MVC5 Google APIs GoogleWebAuthorizationBroker.AuthorizeAsync works locally but not deployed to IIS

白昼怎懂夜的黑 提交于 2020-01-11 10:18:34

问题


I'm having an odd problem trying to get an MVC5 app to work with the Google Mirror API when it's deployed (or any google API for that matter).

This is the code I am struggling to get working:

UserCredential credentials = GoogleWebAuthorizationBroker.AuthorizeAsync(
    new ClientSecrets
    {
        ClientId = "my_client_id",
        ClientSecret = "my_client_Secret"
    },
    new[] { MirrorService.Scope.GlassTimeline }, 
    "username", 
    CancellationToken.None,
    new GlassDataStore()
).Result;

When I run this locally from Visual Studio 2013, everything works perfectly - the above code runs and authenticates, persists to the database and I can continue as normal sending cards etc.

Whenever I deploy this to a "real" server however (mostly to get Subscriptions working) it just hangs forever when the above code is executed. I've setup remote debugging and can see that the code does actually run without an exception, but seems to just stop immediately afterwards.

In the browser the page just sits there loading after this code is called (from a button in this case) and w3p.exe starts to eat memory (Fairly slowly, but its an upwards trend..)

It's been frustrating me all weekend - i've tried so many solutions including implementing the code with the guts of GoogleWebAuthorizationBroker as its really just a helper class, but I see the exact same result.

I've tried deploying to two different servers, and checked that the web.configs are the same each time etc.

Any suggestions? I am expecting this to be something really simple that i've missed, and to be a config issue..given that it works locally.

THanks!

edit: Reading around It appears that using the WebAuthorizationBroker may not be the best way to do it in MVC - I should be doing it manually with GoogleAuthorizationCodeFlows..I will try that in the morning, but still - using the broker works fine on an MVC5 site running in VS2013, so I am stumped!


回答1:


I'm closing this question now - the end answer was to use GoogleAuthorizationCodeFlows to do it properly, all working well now :)

The method I describe in my question is no longer supported by Google.



来源:https://stackoverflow.com/questions/25109878/asp-net-mvc5-google-apis-googlewebauthorizationbroker-authorizeasync-works-local

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!