Google日历redirect_uri_mismatch

我在Visual Studio Express 2012 for Web中有一个网站。

我一直收到谷歌的错误,当我尝试下面的代码时,开发者控制台中列出的重定向uri没有匹配:

private void getEvents() { UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = "CLIENTIDHERE", ClientSecret = "SECRETHERE", }, new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None).Result; // Create the service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential }); List x = service.Events.List("primary").Execute().Items.ToList(); } 

我已经尝试在visual studio中将默认端口设置为8080,并且我在开发人员控制台中列出的URI如下所示:

 http://localhost:8080/QFC/Coach/Manageusers.aspx http://localhost:8080/QFC/* http://localhost:8080/oauth2callback http://localhost:8080/oauth2callback/ http://localhost:8080/authorize http://localhost:8080/authorize/ http://localhost:8080/signin-google 

上面提到的代码在页面加载时从http://localhost:8080/QFC/Coach/Schedule.aspx调用。 每次我收到错误时,端口号都不同,我不知道为什么。 例如http://localhost:57002/authorize/与注册不匹配

我在C#中使用.NET api

我需要知道它为什么这样做以及如何解决它。

http://localhost/authorize/到允许的URI列表中。 这以某种方式使谷歌validation忽略了端口。 但它的确有效!