【问题标题】:Google Calendar redirect_uri_mismatch谷歌日历 redirect_uri_mismatch
【发布时间】:2015-01-06 06:51:52
【问题描述】:

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

当我尝试以下代码时,我不断收到来自 google 的错误消息,提示开发者控制台中列出的重定向 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<Event> 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

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

【问题讨论】:

  • 当您在调试模式下运行 Visual Studio 时,端口会发生变化。您需要弄清楚如何将其设置为不更改端口。
  • 我现在也注意到了……我通过在 uris 列表中添加:localhost/authorize 来修复它。谢谢!
  • 不要忘记接受你自己的答案(如果时间允许的话)然后:)

标签: c# asp.net port google-calendar-api


【解决方案1】:

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

【讨论】:

  • 我遇到了同样的问题,并尝试添加这么多不同的 URI,还有 http(s)://localhost/authorize。问题是端口总是在变化,谷歌不会忽略它!您是否还在项目中为 Google 配置了 OAuth2 身份验证服务?
  • 不,我没有……我为此苦苦挣扎了很长时间,然后将该行添加到允许的 URI 列表中就可以修复它。我什么也没做。
【解决方案2】:

就我而言,我是在没有 Google Calendar API 知识的情况下进行快速入门的。解决方案是添加:

http://localhost/

等待几分钟更新

【讨论】:

    猜你喜欢
    • 2013-07-24
    • 2014-06-20
    • 1970-01-01
    • 2016-04-15
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-12
    相关资源
    最近更新 更多