Currently in my app i am fetching Email, GoogleID, User Name, Gender from Google+.
Here is my code in viewDidLoad:
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.clientID = kClientId;
signIn.scopes = [NSArray arrayWithObjects:
kGTLAuthScopePlusMe,
kGTLAuthScopePlusUserinfoEmail,
kGTLAuthScopePlusLogin ,
nil];
signIn.shouldFetchGoogleUserID = YES;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.delegate = self;
[signIn trySilentAuthentication];
And here is my GPPSignInDelegate
method:
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
if (error)
{
} 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);
GTLServicePlus* plusService = [[GTLServicePlus alloc] init] ;
plusService.retryEnabled = YES;
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPerson *person,
NSError *error) {
if (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);
}
}];
}
}
and
-(void)refreshInterfaceBasedOnSignIn
{
if ([[GPPSignIn sharedInstance] authentication])
{
self.signInButton.hidden = YES;
} else
{
self.signInButton.hidden = NO;
}
}
My question is how can i fetch profile picture URL from Google+? I referred this Getting Google+ profile picture url with user_id but i didn't received accurate answer.