0

I want to fetch events from google calendar First I Tired Authenticate by Google API and follow all steps and end by this error enter image description here

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?

Mohamed Helmy
  • 791
  • 1
  • 8
  • 20
  • Possible duplicate http://stackoverflow.com/q/40591090/1841839 – DaImTo Dec 26 '16 at 21:04
  • It's not duplicate please read it well I solve the 403 error by sdk in sign in my problem is calendar if it have sdk or something solve the problem – Mohamed Helmy Dec 26 '16 at 21:28
  • If you have a fix for user agent disallowed please add anwsers to the three or four out standing questions about it – DaImTo Dec 26 '16 at 21:32
  • What is the 403 error you are getting now? If not disallowed? – DaImTo Dec 26 '16 at 21:33
  • Just follow this link https://developers.google.com/identity/sign-in/ios/ no 403 and sign successfully but it authorized through GIT and calendar take authority from GTM in API – Mohamed Helmy Dec 26 '16 at 21:37
  • Your question is unclear exactly what is the error with your code? – DaImTo Dec 26 '16 at 21:43
  • i have answered it here http://stackoverflow.com/questions/40591090/403-error-thats-an-error-error-disallowed-useragent – Jen Jose Mar 28 '17 at 04:08

0 Answers0