Hello Readers,
After the successful authentication from google plus , the following code snippet is one of the ways that can be used to get the url of the profile image:
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error {
[spinner show:YES];
NSLog(@"Received error %@ and auth object %@",error, auth);
GTLServicePlus* plusService = [[GTLServicePlus alloc] init ];
plusService.retryEnabled = YES;
[plusService setAuthorizer:auth];
// The special value "me" indicates the currently signed in user, but you could use any other valid user ID. Returns a GTLPlusPerson.
GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPerson *person,
NSError *error) {
//person here contains the basic information of the user currently logged in
if (error) {
GTMLoggerError(@"Error: %@", error);
} else {
NSString *imageUrl = person.image.url; // This is the url of the profile image
NSString *emailID=[auth.parameters objectForKeyWithNullCheck:@"email"];
NSString *name=person.displayName;
NSString *idName= [auth.parameters objectForKeyWithNullCheck:@"id_token"];
}
}];
}
0 Comment(s)