The redirect URI in the request: http://localhost:12349/authorize/ did not match a registered redirect URI

11,372

I think you are doing something wrong while "create client id" in GoogleDevelopers Console. Make sure that you have chosed "Installed application" in application type to access your project from console application.

Have a look in the attached image. According to request type you must create clientid and credintials in your registered application in Google Developers Console.

You don't need to define redirect uri in console application while authenticating.

enter image description here

Share:
11,372
Hannan Hossain
Author by

Hannan Hossain

It's not fair enough easy to see things easily. Just try to think, it will be easy enough.

Updated on June 26, 2022

Comments

  • Hannan Hossain
    Hannan Hossain almost 2 years

    I'm getting this error while trying to run my c# console application... I am trying to call google calender api v3 to fetch calender and add event to calender. According to the sample code from google-api-dotnet-client I am doing this.( https://code.google.com/p/google-api-dotnet-client/source/browse/Calendar.VB.ConsoleApp/Program.vb?repo=samples ) Here is the vb.net code. I am using this sample after converting it to c# code.

    Here is my code:

    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                new Program().Run().Wait();
            }
            catch (AggregateException ex)
            {
                foreach (var e in ex.InnerExceptions)
                {
                    Console.WriteLine("ERROR: " + e.Message);
                }
            }
        }
    
        private async Task Run()
        {
            UserCredential credential;
            IList<string> scopes = new List<string>();
    
            CalendarService service;
            scopes.Add(CalendarService.Scope.Calendar);
    
    
            using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
            {
                // problem occuring during executing this statement.
                credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    scopes,
                    "user", CancellationToken.None, new FileDataStore("Calender.SampleApp") );
            }
    
            BaseClientService.Initializer initializer = new BaseClientService.Initializer();
            initializer.HttpClientInitializer = credential;
            initializer.ApplicationName = "C# Calendar Sample";
    
            service = new CalendarService(initializer);
    
            Event newEvent = new Event();
    
            newEvent.Summary = "Appointment";
            newEvent.Description = "Need to meet my Uncle";
    
            IList<EventReminder> reminders = new List<EventReminder>();
            reminders.Add(new EventReminder { Method = "sms", Minutes = 10 });
            newEvent.Reminders = new Event.RemindersData { UseDefault = false, Overrides = reminders };
    
            newEvent.Recurrence = new String[] { "DTSTART;TZID=Bangladesh Standard Time:20140124T163000;RRULE:FREQ=DAILY" };
    
            IList<EventAttendee> attendees = new List<EventAttendee>();
            attendees.Add(new EventAttendee { Email = "[email protected]", Organizer = true, DisplayName = "Hannan" });
            newEvent.Attendees = attendees;
    
            newEvent.GuestsCanInviteOthers = false;
            newEvent.GuestsCanModify = false;
            newEvent.GuestsCanSeeOtherGuests = false;
            newEvent.Location = "Dhaka, Bangladesh";
            newEvent.Start = new EventDateTime { DateTime = DateTime.Now, TimeZone = "Bangladesh Standard Time" };
    
            Event recurringEvent = service.Events.Insert(newEvent, "primary").Execute();
    
            var list = await service.CalendarList.List().ExecuteAsync();
        }
    }
    

    This is my redirect URIs in my GoogleDevelopers Console project.

    Redirect URIs: http://localhost:7744/authorize/
    

    And this is the error message shown in browser.

    enter image description here

    I couldn't find any way to resolve this problem. Some help will be appreciable. I also search all the realted post in stackoverflow. But I couldn't find it's solution.