4

i am using Gdata and already suceessfully login gmail and call below method

 - (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
  finishedWithAuth:(GTMOAuth2Authentication *)auth{
  if (error != nil) {

   }
  else{
     // i got successful login here
     self.auth=auth;
  }
}

in above method i got Authentifacation token and etc. Now

NSString *urlStr =   @"https://www.google.com/m8/feeds/contacts/default/full";
NSURL *url = [NSURL URLWithString:urlStr];
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] autorelease];


                                           } else {
                      // fetch failed
                      output = [error description];
                  }
              }
          }]; 

but i got error 401 please helpful me

Developer
  • 760
  • 3
  • 15
  • could u tell me how r u log in using gdata. please any link which i could follow for login in gmail using gdata not google plus api – ChenSmile Jan 22 '15 at 09:32

0 Answers0