I’m working on a Mac OS X app, where the user will need to access their Google Calendar. However, I can’t get the authentication to work and it doesn’t really make any sense to me why it’s not working.
Google API is installed via Cocoapods: pod ‘Google-API-Client/Calendar'
I’ve got a NSTabViewController inside a NSWindow, when a user clicks a button I called the following:
@property (nonatomic, strong)GTMOAuth2WindowController *windowController;
static NSString *const scope = @"https://www.googleapis.com/auth/calendar";
GTMOAuth2Authentication *auth;
auth = [GTMOAuth2WindowController authForGoogleFromKeychainForName:kKeychainItemName clientID:kClientID clientSecret:kClientSecret];
if ( auth.canAuthorize) {
return;
}
self.windowController = [[GTMOAuth2WindowController alloc] initWithScope:scope
clientID:kClientID
clientSecret:kClientSecret
keychainItemName:kKeychainItemName
resourceBundle:nil];
[self.windowController signInSheetModalForWindow:self.view.window
delegate:self
finishedSelector:@selector(windowController:finishedWithAuth:error:)];
}
- (void)windowController:(GTMOAuth2WindowController *)windowController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
}
Don’t know why, but the selector is never called. From debug I noticed the Fetcher starts, and kGTMOAuth2UserSignedIn gets posted, but it never ends.
Any ideas why this isn’t working?
- (void)signIn {
[self runSigninCompletion:^{ [self fetchCalendarList]; }];
}
- (void)runSigninCompletion:(void(^)(void))signInDoneBlock {
// Show the OAuth 2 sign-in controller
NSBundle *frameworkBundle = [NSBundle bundleForClass:[GTMOAuth2WindowController class]];
GTMOAuth2WindowController *windowController;
windowController = [GTMOAuth2WindowController controllerWithScope:kGTLAuthScopeCalendar
clientID:kClientID
clientSecret:kClientSecret
keychainItemName:kKeychainItemName
resourceBundle:frameworkBundle];
NoteAppDelegate *appDelegate = (NoteAppDelegate *)[NSApp delegate];
[windowController signInSheetModalForWindow:[appDelegate window]
completionHandler:^(GTMOAuth2Authentication *auth,
NSError *error) {
if (error == nil) {
self.calendarService.authorizer = auth;
if (signInDoneBlock) {
signInDoneBlock();
}
} else {
[self presentError:error];
}
[self postSignInChanged];
}];
}
--
You received this message because you are subscribed to the Google Groups "Google APIs Client Library for Objective-C" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-api-objective...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.