Создание проблемы события с Google calendar API v3
Я застрял на документации google calendar API v3.
Я действительно получаю события, созданные внутри веб-интерфейса google calendar, но как только я пытаюсь поместить новое событие в календарь через свой проект .net, я получаю ошибку:
Недостаточное Разрешение [403]
Ошибки [
Сообщение[недостаточное разрешение] местоположение[ - ] причина[недостаточные разрешения] Домен[глобальный]
]
Hope somebody could help solving this error! In my opinion the documentation and also the vb.net examples are not giving any solution.
Что я уже пробовал:
<pre>Imports Google.Apis.Auth.OAuth2 Imports Google.Apis.Calendar.v3 Imports Google.Apis.Calendar.v3.Data Imports Google.Apis.Calendar.v3.EventsResource Imports Google.Apis.Services Imports Google.Apis.Util.Store Imports System Imports System.IO Imports System.Linq Imports System.Text Imports System.Threading Imports System.Threading.Tasks Imports System.Windows.Forms Imports System.Collections.Generic Imports Calendar Public Class Form1 Shared Scopes As String() = {CalendarService.Scope.CalendarReadonly} Shared ApplicationName As String = "Google Calendar API .NET Quickstart" Dim m_appointments As New List(Of Appointment) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim credential As UserCredential Using stream = New FileStream("client_secret.json", FileMode.Open, FileAccess.Read) Dim credPath As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json") credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, New FileDataStore(credPath, True)).Result Console.WriteLine("Credential file saved to: " & credPath) End Using Dim service = New CalendarService(New BaseClientService.Initializer() With {.HttpClientInitializer = credential, .ApplicationName = ApplicationName}) Dim request As EventsResource.ListRequest = service.Events.List("primary") request.TimeMin = DateTime.Now request.ShowDeleted = False request.SingleEvents = True request.MaxResults = 10 request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime Dim events As Events = request.Execute() If events.Items IsNot Nothing AndAlso events.Items.Count > 0 Then For Each [Event] In events.Items Dim app As New Appointment app.StartDate = [Event].Start.DateTime app.EndDate = [Event].End.DateTime app.Title = [Event].Summary m_appointments.Add(app) Next Else End If DayView2.AllowNew = True DayView2.StartDate = Now End Sub Private Sub DayView2_Click(sender As Object, e As EventArgs) Handles DayView2.Click 'Create NEW event in dayview Dim credential As UserCredential Using stream = New FileStream("client_secret.json", FileMode.Open, FileAccess.Read) Dim credPath As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json") credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, New FileDataStore(credPath, True)).Result End Using Dim service = New CalendarService(New BaseClientService.Initializer() With {.HttpClientInitializer = credential, .ApplicationName = ApplicationName}) Dim CalendarEvent As New Google.Apis.Calendar.v3.Data.Event Dim request As EventsResource.InsertRequest Dim StartDateTime As New Google.Apis.Calendar.v3.Data.EventDateTime Dim enddatetime As New Google.Apis.Calendar.v3.Data.EventDateTime Dim A As Date = "16/01/2018 13:00" StartDateTime.DateTime = A Dim B As Date = "16/01/2018 14:00" enddatetime.DateTime = B CalendarEvent.Start = StartDateTime CalendarEvent.End = enddatetime CalendarEvent.Id = System.Guid.NewGuid.ToString CalendarEvent.ICalUID = CalendarEvent.Id CalendarEvent.Summary = "Test" service.Events.Insert(CalendarEvent, "primary").Execute() End Sub End Class