I\'ve managed to successfully log in to google plus from an iPhone app. But how to get logged in user\'s details? such as profile id, email etc.
I tried this, Stackoverf
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error {
NSLog(@"Received Error %@ and auth object==%@", error, auth);
if (error) {
// Do some error handling here.
} else {
[self refreshInterfaceBasedOnSignIn];
GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];
NSLog(@"email %@ ", [NSString stringWithFormat:@"Email: %@",[GPPSignIn sharedInstance].authentication.userEmail]);
NSLog(@"Received error %@ and auth object %@",error, auth);
// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[GTLServicePlus alloc] init] ;
plusService.retryEnabled = YES;
// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
// 3. Use the "v1" version of the Google+ API.*
plusService.apiVersion = @"v1";
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPerson *person,
NSError *error) {
if (error) {
//Handle Error
} else {
NSLog(@"Email= %@", [GPPSignIn sharedInstance].authentication.userEmail);
NSLog(@"GoogleID=%@", person.identifier);
NSLog(@"User Name=%@", [person.name.givenName stringByAppendingFormat:@" %@", person.name.familyName]);
NSLog(@"Gender=%@", person.gender);
}
}];
}
}
Hope, this will help you