I want to fetch events from google calendar
First I Tired Authenticate by Google API and follow all steps and end by this error
After Few Search convert code to google SDK on this https://developers.google.com/identity/sign-in/ios/
and Authenticate successfully
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if let error = error {
print("\(error.localizedDescription)")
// [START_EXCLUDE silent]
NotificationCenter.default.post(
name: Notification.Name(rawValue: "ToggleAuthUINotification"), object: nil, userInfo: nil)
// [END_EXCLUDE]
} else {
// Perform any operations on signed in user here.
let userId = user.userID // For client-side use only!
let idToken = user.authentication.idToken // Safe to send to the server
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
// [START_EXCLUDE]
NotificationCenter.default.post(
name: Notification.Name(rawValue: "ToggleAuthUINotification"),
object: nil,
userInfo: ["statusText": "Signed in user:\n\(fullName)"])
// [END_EXCLUDE]
}
}
every think working well but the problem in the after Authenticate i want to access calendar and get events https://developers.google.com/google-apps/calendar/quickstart/ios
- (void)fetchEvents {
GTLQueryCalendar *query = [GTLQueryCalendar queryForEventsListWithCalendarId:@"primary"];
query.maxResults = 10;
query.timeMin = [GTLDateTime dateTimeWithDate:[NSDate date]
timeZone:[NSTimeZone localTimeZone]];;
query.singleEvents = YES;
query.orderBy = kGTLCalendarOrderByStartTime;
[self.service executeQuery:query
delegate:self
didFinishSelector:@selector(displayResultWithTicket:finishedWithObject:error:)];
}
each time give me 403 error and I can't find any solution of SDK to solve this, so any Suggestion?