Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

C# Google Calendar API - Credentials/Microsoft Account

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...