Asked by:
Asp.net google calendar api

Question
-
User-2131774580 posted
I have Application to send data to Google Calendar API
everything is fine while run the application from Loca and data posted to Google Calendar
once running from IIS or from hosting server it return error
- first it is return error for access denied for google API
- then i changed the code to save the authentication file to specific folder
it is return error with access denied if i use IIS with Network Service or local System
for ApplicationPoolIdentity it is just loading :
the below is the code i am using
var folder = System.Web.HttpContext.Current.Server.MapPath("/google_folder");
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "1009294026329-7a0s8pdf8f1c2i8ic2c11dktfea4cvn1.apps.googleusercontent.com",
ClientSecret = "fEljiEW39Epm_Twwqv4-yEZ5",
},
new[] { CalendarService.Scope.Calendar },
"user",
CancellationToken.None,
new FileDataStore(folder)).Result;
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "Appspace Calendar",
});
Event newEvent = new Event()
{
Summary = Reservation_Reason,
Location = Room_No,
Description = Remarks,
Start = new EventDateTime()
{
DateTime = DateTime.Parse(Date_with_Start_Time),
//DateTime = DateTime.Parse(Date_with_Start_Time),
TimeZone = "Asia/Riyadh",
},
End = new EventDateTime()
{
DateTime = DateTime.Parse(Date_with_End_Time),
//TimeZone = "America/Los_Angeles",
TimeZone = "Asia/Riyadh",
},
Recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=1" },
//Attendees = new EventAttendee[] {
//new EventAttendee() { Email = "lpage@example.com" },
//new EventAttendee() { Email = "sbrin@example.com" },
//},
Reminders = new Event.RemindersData()
{
UseDefault = false,
Overrides = new EventReminder[] {
new EventReminder() { Method = "email", Minutes = 24 * 60 },
new EventReminder() { Method = "sms", Minutes = 10 },
}
}
};
String calendarId = "primary";
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
Event createdEvent = request.Execute();
the error appear :
System.ComponentModel.Win32Exception: Access is denied
i give google folder access by administrator - IIS_User same thingSaturday, November 19, 2016 9:18 AM
All replies
-
User-2057865890 posted
Hi Ikrami,
Add the name of the file to the end of the path.
var filename = "credentials.json"; var folder = System.Web.HttpContext.Current.Server.MapPath("/google_folder"+ filename);
Best Regards,
Chris
Monday, November 21, 2016 4:09 AM -
User-2131774580 posted
Same error, also in deployment server , it is just loading
Monday, November 21, 2016 7:58 PM -
User1847352307 posted
Please check following link. This would be helpful.
https://developers.google.com/google-apps/calendar/quickstart/dotnet
Tuesday, November 22, 2016 10:36 AM -
User-2131774580 posted
If the Host ( Deployment Server) myasp.net the server not support to open popup window , the form which i have to enter my user nad password for google
so my code execute while saving the record, it is just loading
Tuesday, November 22, 2016 2:44 PM