Google Calendar redirect_uri_mismatch

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 22:35:31

问题


I have a website in Visual Studio Express 2012 for Web.

I keep getting an error from google which says there isn't a match for the redirect uri's listed in the developer console when I try the code below:

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();
    }

I have already tried setting the default port to 8080 in visual studio and the URI's listed in my developer console are as follows:

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

The code mentioned above is called from http://localhost:8080/QFC/Coach/Schedule.aspx on page load. Each time I get the error the port number is different and I have no idea why. e.g. http://localhost:57002/authorize/ did not match a registered

I am using the .NET api with C#

I need to know why it's doing this and how to fix it.


回答1:


Added http://localhost/authorize/ to the list of allowed URI's. This somehow makes google verification ignore the port. But it works!



来源:https://stackoverflow.com/questions/27793556/google-calendar-redirect-uri-mismatch

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