1

Well, my problem is that I have to register the calendar in my personal google account which isn't a problem but...

When creating a new event, my personal e-mail will display there as an Organizer and will put the event in my personal calendar as well.

In the company, we use Microsoft 365 accounts which would be the best to use. I mean, is there a way to solve this?

The best way to solve this is that when I create the event, I give it a string (which is a microsoft email) and that should be the organizer (in spite of the fact that it's not a google account). The main problem is that I have to pre register the ClientID in the application to run the whole process. I use the following right now with google account:

public static CalendarService getCalendarService
{
   get
   {
      var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret },
      new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None).Result;
      return new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "Deadline calendar" });
    }
}
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Nagy Szabolcs
  • 227
  • 1
  • 9

1 Answers1

1

The problem you have is that the owner of an event is the one who created it. The one who created it is the currently authenticated user. Basically what ever account you logged in with and consented to the access and ran your application from.

You would need to covert the Microsoft 365 email account to a google account, then login with that account, create events with that account and then it will be the owner.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Yeah, but the creator should always be different. So we're talking about basic secretary who doesn't even know what Google Calendar API is, so I'd need a simple method so everyone can be a creator which is given by a string in the code. I'm trying to do your published method (with P12 key - with service account) but the keyFilePath is a problem to find. I mean, I included the .p12 file in the project, the same folder as the class which calls it but still can't find the file. Tried almost every single type of method to determine the path, but still nothing. I use X509Certificate2 – Nagy Szabolcs Jan 12 '21 at 16:04
  • The context is the following. Someone creates a project whith a custom email (mostly company email) and the responsible person of the current project will be the event organizer. – Nagy Szabolcs Jan 12 '21 at 16:11
  • 1
    if you use a service account then it will be the owner and the name will be even worse. option teach them google calendar or stop using Google calendar. Even if you patch the owner of the event their account still needs to be a Google account – Linda Lawton - DaImTo Jan 12 '21 at 18:33