In my iPhone app I am using google sign in using Oauth2
, I am following this insturction and successfully login in
- (void)viewController:(GTMOAuth
Solved it using this code
NSURL *url = [NSURL URLWithString:@"https://www.googleapis.com/plus/v1/people/me/activities/public"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[self.auth authorizeRequest:request
completionHandler:^(NSError *error) {
NSString *output = nil;
if (error) {
output = [error description];
} else {
// Synchronous fetches like this are a really bad idea in Cocoa applications
//
// For a very easy async alternative, we could use GTMHTTPFetcher
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if (data) {
// API fetch succeeded
output = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding] ;
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&error];
NSArray *array=[json objectForKey:@"items"];
if (array.count>0) {
NSDictionary *dicts=[array objectAtIndex:0];
// NSLog(@"actor:%@",[dicts objectForKey:@"actor"]);
//[self updateUI:[dicts objectForKey:@"actor"]];
// [dictUserInfo setObject:[[[dicts objectForKey:@"actor"] objectForKey:@"image"]objectForKey:@"url"] forKey:@"imageUrl"];
if([delegate respondsToSelector:@selector(userPicChanged:)])
{
//send the delegate function with the amount entered by the user
[delegate userPicChanged:[[[dicts objectForKey:@"actor"] objectForKey:@"image"]objectForKey:@"url"]];
}
}
} else {
// fetch failed
output = [error description];
}
}
}];