0

I have this code that has worked in the past, but now seems to not work. It is a stripped-down example of the actual Google code from github. Essentially, I set theUsername and thePassword to a google account containing spreadsheets at the top level in Google Drive, then call 'fetch', expecting there to be no error returned (and there was no error in the past...). Instead, I get an NSError with description of 'Domain=com.google.GDataServiceDomain' and code of '404'.

I've checked the account, and there are spreadsheets there, exactly as there were before. I'm lost - has the spreadsheets API changed? Is there an easy fix for this? I have dozens of projects crafted around the objective C spreadsheet APIs and the APIs for Objective C aren't exactly updated regularly. Help!

- (void)findSpreadsheet
{
    if (mSpreadsheetFetchError == nil)
    {
        // Look for named spreadsheet
    }
    else
    {
        NSLog(@"Error fetching spreadsheet '%@': %@", self.spreadsheetName, [mSpreadsheetFetchError description]);
        self.fetchInProgress = NO;
    }
}

- (GDataServiceGoogleSpreadsheet *)spreadsheetService
{
    static GDataServiceGoogleSpreadsheet* service = nil;

    if (!service)
    {
        service = [[GDataServiceGoogleSpreadsheet alloc] init];

        [service setShouldCacheResponseData:YES];
        [service setServiceShouldFollowNextLinks:YES];
    }

    [service setUserCredentialsWithUsername:self.theUsername
                                   password:self.thePassword];

    return service;
}

- (void)fetch
{        
    [self setSpreadsheetFeed:nil];
    [self setSpreadsheetFetchError:nil];

    [self setWorksheetFeed:nil];
    [self setWorksheetFetchError:nil];

    [self setEntryFeed:nil];
    [self setEntryFetchError:nil];

    mIsSpreadsheetFetchPending = YES;

    NSLog(@"Submitting fetch request...");

    GDataServiceGoogleSpreadsheet *service = [self spreadsheetService];
    NSURL *feedURL = [NSURL URLWithString:kGDataGoogleSpreadsheetsPrivateFullFeed];
    [service fetchFeedWithURL:feedURL
                     delegate:self
            didFinishSelector:@selector(feedTicket:finishedWithFeed:error:)];
}

// spreadsheet list fetch callback
- (void)feedTicket:(GDataServiceTicket *)ticket
  finishedWithFeed:(GDataFeedSpreadsheet *)feed
             error:(NSError *)error
{
    [self setSpreadsheetFeed:feed];
    [self setSpreadsheetFetchError:error];

    mIsSpreadsheetFetchPending = NO;
    [self findSpreadsheet];
}
  • Possibly related to http://stackoverflow.com/questions/30530455/google-spreadsheet-service-using-oauth-2-0-c-sharp?rq=. I'm checking if I'm still using OAuth 1.0 but was pretty sure I wasn't... – Billy Nickerson Mar 14 '16 at 04:37

1 Answers1

0

Implemented an OAuth2 solution using examples of code from Google.

  • Oh, and had to add some code to change the iOS web browser user agent string to avoid yet another pitfall base on error code 403. – Billy Nickerson Jul 09 '17 at 06:55