I want to get the People list from Google+ in the iOS app.
I am using the Google+ tutorial api listed at
https://developers.google.com/+/mobile/ios/getting-started
I created a new project in the Google+ Developer Console, link
https://console.developers.google.com/project
Getting the following error in - (void) getPeopleInfo.
[lvl = 3] __31- [ViewController getPeopleInfo] _block_invoke () Error: Domain error = com.google.GTLJSONRPCErrorDomain Code = 401 "Operation could not be completed. (Invalid credentials)" UserInfo = 0x14d89340 {error = InvalidStrurdrerdrrdrdr, = GTLErrorObject 0x14d855e0: {message: "Invalid credentials": 401: [1]}, NSLocalizedFailureReason = (Invalid credentials)} 2014-03-13 12: 40: 21.026 GPlusDemo [636 / 0x3d35718c] [lvl = 3] __31 - [ViewController getPeopleInfo] _block_invoke () Error: Domain error = com.google.GTLJSONRPCErrorDomain Code = 401 "Operation could not be completed. (Invalid credentials)" UserInfo = 0x14d85f90 {error = Invalid Credentials, GTLStructuredErbb = 0rrorb = 0rrorb = 0rrorb = 0rrorb = 0rrorb = 0rrorb = 0rrorb = 0rrorb 0 : "Invalid even data "401 data [1]},NSLocalizedFailureReason = (Invalid Credentials)}
ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.clientID = kClientId;
signIn.scopes = @[ kGTLAuthScopePlusLogin];
signIn.scopes = @[ @"profile" ];
signIn.delegate = self;
[signIn trySilentAuthentication];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(void)refreshInterfaceBasedOnSignIn
{
if ([[GPPSignIn sharedInstance] authentication]) {
NSLog(@"Login");
self.signInButton.hidden = YES;
[self getPeopleInfo];
} else {
self.signInButton.hidden = NO;
}
}
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error
{
NSLog(@"Received error %@ and auth object %@",error, auth);
if (error) {
} else {
[self refreshInterfaceBasedOnSignIn];
}
}
- (void)signOut {
[[GPPSignIn sharedInstance] signOut];
}
- (void)disconnect {
[[GPPSignIn sharedInstance] disconnect];
}
- (void)didDisconnectWithError:(NSError *)error {
if (error) {
NSLog(@"Received error %@", error);
} else {
}
}
-(void)getPeopleInfo
{
GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
plusService.retryEnabled = YES;
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
GTLQueryPlus *query =
[GTLQueryPlus queryForPeopleListWithUserId:@"me"
collection:kGTLPlusCollectionVisible];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPeopleFeed *peopleFeed,
NSError *error) {
if (error) {
GTMLoggerError(@"Error: %@", error);
} else {
NSArray* peopleList = [peopleFeed.items mutableCopy];
NSLog(@"peopleList:%@", peopleList);
}
}];
}