0

I'm having problems trying to write a VB program using VS2015 to create an event in Googles Calendar using their API, there seems a distinct lack of information regarding the API and VB. I've posted my entire code below and the problem I'm getting is on the line : -

Dim createdEvent As [Event] = request.Execute(), the error I get is Insufficient Permission [403] Errors [ Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]

can anyone help please

Imports Google.Apis.Auth.OAuth2
Imports Google.Apis.Calendar.v3
Imports Google.Apis.Calendar.v3.Data
Imports Google.Apis.Services
Imports Google.Apis.Util.Store
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Text
Imports System.Threading
Imports System.Threading.Tasks
Imports Google.Apis.Calendar.v3.EventsResource
Imports Google.Apis.Requests


 Public Class Form1

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
   SurroundingSub()
 End Sub

 Private Sub SurroundingSub()   
Dim service = Authenticate()
    Dim newEvent As [Event] = New [Event]() With {
    .Summary = "Google I/O 2015",
    .Location = "800 Howard St., San Francisco, CA 94103",
    .Description = "A chance to hear more about Google's developer products.",
    .Start = New EventDateTime() With {
        .DateTime = DateTime.Parse("2015-05-28T09:00:00-07:00"),
        .TimeZone = "America/Los_Angeles"
    },
    .[End] = New EventDateTime() With {
        .DateTime = DateTime.Parse("2015-05-28T17:00:00-07:00"),
        .TimeZone = "America/Los_Angeles"
    },
    .Recurrence = New String() {"RRULE:FREQ=DAILY;COUNT=2"},
    .Attendees = New EventAttendee() {New EventAttendee() With {
        .Email = "mickburden@btinternet.com"
    }, New EventAttendee() With {
        .Email = "mickburden@btinternet.com"
    }},
    .Reminders = New [Event].RemindersData() With {
        .UseDefault = False,
        .[Overrides] = New EventReminder() {New EventReminder() With {
            .Method = "email",
            .Minutes = 24 * 60
        }, New EventReminder() With {
            .Method = "sms",
            .Minutes = 10
        }}
    }
}

    Dim calendarId As String = "primary"
    Dim request As EventsResource.InsertRequest = service.Events.Insert(newEvent, calendarId)
    Dim createdEvent As [Event] = request.Execute()
   End Sub


    Private Function Authenticate()
    Dim scopes = New List(Of String)
    scopes.Add(CalendarService.Scope.Calendar)

    Dim credential As UserCredential
    Using stream As New FileStream("credentials.json", FileMode.Open, FileAccess.Read)
        '     Using stream As New FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)
        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None,
                New FileDataStore("Calendar.VB.Sample")).Result
    End Using

    Dim initializer As New BaseClientService.Initializer()
    initializer.HttpClientInitializer = credential
    initializer.ApplicationName = "VB.NET Calendar Sample"
    Dim service
    service = New CalendarService(initializer)
    Return service
    End Function 

end class
Sam Axe
  • 33,313
  • 9
  • 55
  • 89
  • Possible duplicate of [google plus api: "insufficientPermissions" error](https://stackoverflow.com/questions/16978192/google-plus-api-insufficientpermissions-error) – David Wilson Nov 07 '18 at 22:15
  • Thanks David, I've checked that link and there was nothing there that could help me with this particular problem – Mick Burden Nov 08 '18 at 18:24
  • I'd like to find a complete VB version of code that works that I can learn from and hopefully expand on myself, Initially I just want to be able to save a single event to my Calendar. Is there anyone out there that has achieved this and is willing to share their code ? – Mick Burden Nov 08 '18 at 18:45

0 Answers0