URI การเปลี่ยนเส้นทางในคำขอ: http://localhost:12349/authorize/ ไม่ตรงกับ URI การเปลี่ยนเส้นทางที่ลงทะเบียนไว้

ฉันได้รับข้อผิดพลาดนี้ขณะพยายามเรียกใช้แอปพลิเคชันคอนโซล c# ของฉัน... ฉันกำลังพยายามเรียก google calender api v3 เพื่อดึงข้อมูลปฏิทินและเพิ่มกิจกรรมลงในปฏิทิน ตามโค้ดตัวอย่างจาก google-api-dotnet-client ฉันกำลังทำสิ่งนี้ ( https://code.google.com/p/google-api-dotnet-client/source/browse/CalendarVB.ConsoleApp/Program.vb?repo=samples ) นี่คือโค้ด vb.net ฉันใช้ตัวอย่างนี้หลังจากแปลงเป็นโค้ด c#

นี่คือรหัสของฉัน:

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

นี่คือ URI การเปลี่ยนเส้นทางของฉันในโครงการ GoogleDevelopers Console

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

และนี่คือข้อความแสดงข้อผิดพลาดที่แสดงในเบราว์เซอร์

ป้อนคำอธิบายรูปภาพที่นี่

ฉันไม่พบวิธีแก้ไขปัญหานี้ ความช่วยเหลือบางอย่างจะได้รับการชื่นชม ฉันยังค้นหาโพสต์ realted ทั้งหมดใน stackoverflow ด้วย แต่ฉันไม่พบวิธีแก้ปัญหา


person Hannan Hossain    schedule 24.01.2014    source แหล่งที่มา
comment
หมายเลขพอร์ตไม่ตรงกัน และหมายเลขพอร์ตเป็นส่วนสำคัญของการระบุตัวตนของ HTTP uri   -  person Damien_The_Unbeliever    schedule 24.01.2014
comment
@Damien_The_Unbeliever ฉันรู้ แต่ฉันไม่ได้กำหนด uri การเปลี่ยนเส้นทางในแอปพลิเคชันคอนโซลของฉัน วิธีการกำหนดสิ่งนั้น   -  person Hannan Hossain    schedule 24.01.2014
comment
@Damien_The_Unbeliever ฉันจะกำหนดเส้นทาง uri จากแอปพลิเคชันคอนโซลระหว่างการจับคู่ข้อมูลรับรองได้อย่างไร   -  person Hannan Hossain    schedule 27.01.2014
comment
คุณไม่จำเป็นต้องกำหนด uri การเปลี่ยนเส้นทางในแอปพลิเคชันคอนโซลขณะตรวจสอบสิทธิ์ โปรดดูคำตอบของฉัน ฉันคิดว่านี่จะช่วยแก้ปัญหาของคุณได้   -  person SKD    schedule 27.01.2014


คำตอบ (2)


ฉันคิดว่าคุณกำลังทำอะไรผิดในขณะที่ "สร้างรหัสลูกค้า" ใน GoogleDevelopers Console ตรวจสอบให้แน่ใจว่าคุณได้เลือก "แอปพลิเคชันที่ติดตั้ง" ในประเภทแอปพลิเคชันเพื่อเข้าถึงโครงการของคุณจากแอปพลิเคชันคอนโซล

ลองดูตามภาพที่แนบมาครับ ตามประเภทคำขอ คุณต้องสร้างรหัสลูกค้าและข้อมูลรับรองในแอปพลิเคชันที่ลงทะเบียนของคุณใน Google Developers Console

คุณไม่จำเป็นต้องกำหนด uri การเปลี่ยนเส้นทางในแอปพลิเคชันคอนโซลขณะตรวจสอบสิทธิ์

ป้อนคำอธิบายรูปภาพที่นี่

person SKD    schedule 27.01.2014
comment
หากคุณใช้แอปพลิเคชันคอนโซล ให้เลือกอื่นๆ เพื่อสร้างรหัสไคลเอ็นต์ - person Brijesh Bhagavath; 22.10.2017

ฉันมีข้อผิดพลาดนี้ในโปรแกรมทดสอบทั่วไป (https://ctrlq.org/google.apps.script/docs/guides/rest/quickstart/dotnet.html) และบังเอิญว่า client_secret.json ผิด ดาวน์โหลดอีกครั้งและใช้งานได้ .

person Chesare    schedule 08.06.2018