We are facing an issue at the time of redirection to create Google calendar event URL Error: enter image description here
Access blocked: project-Client_Id request is invalid, You can’t sign in because project-Client_Id sent an invalid request. You can try again later, or contact the developer about this issue.
We had created the object of the Event. Then added the event to Google Calendar.
Library Used : googleapis: ^11.3.0 googleapis_auth: ^1.4.1 url_launcher: ^6.1.12
class CalendarClient {
static const _scopes = [CalendarApi.calendarScope];
insert(title, startTime, endTime) {
var _clientID = new ClientId(
"Client_ID",
"");
clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient
client) {
var calendar = CalendarApi(client);
calendar.calendarList.list().then((value) =>
print("VAL________$value"));
String calendarId = "primary";
Event event = Event(); // Create object of event
event.summary = title;
EventDateTime start = new EventDateTime();
start.dateTime = startTime;
start.timeZone = "GMT+05:00";
event.start = start;
EventDateTime end = new EventDateTime();
end.timeZone = "GMT+05:00";
end.dateTime = endTime;
event.end = end;
try {
calendar.events.insert(event, calendarId).then((value) {
print("ADDEDDD_________________${value.status}");
if (value.status == "confirmed") {
log('Event added in google calendar');
} else {
log("Unable to add event in google calendar");
}
});
} catch (e) {
log('Error creating event $e');
}
});
}
void prompt(String url) async {
print("Please go to the following URL and grant access:");
print(" => $url,, Start Time >> ");
print("");
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {
throw 'Could not launch $url';
}
}
}