ASP.NET MVC5 Google API GoogleWebAuthorizationBroker.AuthorizeAsync 在服务器中不起作用

ASP.NET MVC5 Google APIs GoogleWebAuthorizationBroker.AuthorizeAsync not work in server

ASP.NET MVC5 Google APIs GoogleWebAuthorizationBroker.AuthorizeAsync AdSense 管理 API,在本地工作但不在服务器中工作,

GoogleWebAuthorizationBroker.Folder = "Google.Apis.Auth";

                var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    new ClientSecrets
                    {
                        ClientId = "XXXX",
                        ClientSecret = "XXXX"
                    },
                    new string[] { AdSenseService.Scope.Adsense },
                    "SampleApp",
                    CancellationToken.None).Result;

                var service = new AdSenseService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                });

有什么建议吗?我希望这是我错过的非常简单的事情,并且是一个配置问题..鉴于它在本地工作。

您是否更改了重定向 URI 以指向应用程序的身份验证端点。

在本地测试时 was/is 最有可能设置为 http://localhost:8080, where as on your server it should be set to something like: http://example.com/oauth2callback

Using OAuth 2.0 for Web Server Applications