I'm having a headache because of google calendar API. My goal is to access my private calendar, and share some details through a web interface I will create, the problem is that after following all of the steps, I still get the response as empty and no errors to know exactly what the problem is... steps I have done so far:
- Created a service account and downloaded a json file.
- Went to admin.google.com > Security > Access and data control > API Controls > Domain-wide delegation as follows
- Added my C# code as follows:
GoogleCredential credential;
using (var stream = new FileStream("googlekey2.json", FileMode.Open, FileAccess.Read))
{
stream.Position = 0;
credential = GoogleCredential.FromStream(stream)
.CreateScoped(new string[] { CalendarService.Scope.Calendar, CalendarService.Scope.CalendarEvents });
}
Service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Google Test App",
});
and the response is just an empty object, with no errors...
Thank you for any help you may bring on how to correctly setup this on .net core app to show some results, some calendar information, I also did share my calendar with the service account e-mail address as suggested by some users around here but the result is the same, no errors but simply nothing inside...
In regards of ms Linda's answer, yes I did setup DOMAIN WIDE DELEGATION with the roles I want but I can't make it work for some reason.
OTHER INFO: I'm not trying to make a user login with a google form or similar, this is for server - server communication, in other words it should access my calendar without any interaction from the user, no user should be involved, this is why I'm taking the "Service Account" option with domain delegation.
Thank you for any help.