Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Calendar redirect_uri_mismatch

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.

like image 354
msbarnard Avatar asked Sep 07 '25 15:09

msbarnard


1 Answers

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

like image 74
msbarnard Avatar answered Sep 10 '25 04:09

msbarnard