tlababidi / google-api-objectivec-client

Automatically exported from code.google.com/p/google-api-objectivec-client
0 stars 0 forks source link

GTLServiceTicket not executing #47

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Creating a service ticket for uploading a file with the query
        GTLQueryYouTube *query = [GTLQueryYouTube queryForVideosInsertWithObject:video
                                                                            part:@"snippet,status"
                                                                uploadParameters:uploadParameters];
        The query is fine, unchanged, and has only stopped working since i implemented G+ sign in.

2. Attempting to execute the query using 
        _uploadFileTicket = [service executeQuery:query
                                completionHandler:^(GTLServiceTicket *ticket,
                                                    GTLYouTubeVideo *uploadedVideo,
                                                    NSError *error) {
                                    // Callback
                                    NSLog(@"Here!");
                                    //More stuff including error handling
3.

What is the expected output? What do you see instead? Expected at least 'Here' 
to log, and any errors to be handled following the unsuccessful upload. Instead 
nothing appears, the query just doesnt execute. 

What version of the product are you using? On what operating system?
Latest svn on 10.8.4 xCode 5. 

Please provide any additional information below.
How would i go about tracing where this ticket gets stuck? I just cant follow 
it at all. Im so confused. Any help on how to start fresh and re-do this all 
would be great. 
No compiler errors/warnings associated.

Original issue reported on code.google.com by michael....@trickbook.com on 20 Sep 2013 at 9:05

GoogleCodeExporter commented 9 years ago
I should also note that the auth prior to this works fine. 

Original comment by michael....@trickbook.com on 20 Sep 2013 at 9:07

GoogleCodeExporter commented 9 years ago
Is the query being executed on the main thread?
Is authentication being done with the same scopes as previously?
Are any exceptions firing?

Original comment by grobb...@google.com on 20 Sep 2013 at 7:55

GoogleCodeExporter commented 9 years ago
Yes - using 

        [[NSOperationQueue mainQueue] addOperationWithBlock:^ {
        _uploadFileTicket = [service executeQuery:query
                                completionHandler:^(GTLServiceTicket *ticket,
                                                    GTLYouTubeVideo *uploadedVideo,
                                                    NSError *error) {
                                                    //Carry on

Is this the right way to go about it? I'm not fully confident with operation 
queues, but could there be anything potentially blocking the operation queue? 
How would I go about checking this? 

I've taken the other authentications out and still the same error. Auth done 
using 

    NSString *clientID = @"myClientID";
    NSString *clientSecret = @"mySecret";
    GTMOAuth2Authentication *auth =
    [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
                                                          clientID:clientID
                                                      clientSecret:clientSecret];
    self.youTubeService.authorizer = auth;

    SEL finishedSel = @selector(viewController:finishedWithAuth:error:);

    GTMOAuth2ViewControllerTouch *viewController;
    viewController = [GTMOAuth2ViewControllerTouch controllerWithScope:kGTLAuthScopeYouTube
                                                              clientID:clientID
                                                          clientSecret:clientSecret
                                                      keychainItemName:kKeychainItemName
                                                              delegate:self
                                                      finishedSelector:finishedSel];
    [self presentViewController:viewController animated:NO completion:nil];
    // [[self navigationController]pushViewController:viewController animated:YES];

Nope no exceptions firing that I can see - where could I go and further 
investigate this? Where would I put my breakpoints/NSLogs?

I've put a log message in GTLYoutubeQuery.m's file, and this method is getting 
called
 + 
(id)queryForVideosInsertWithObject:(GTLYouTubeVideo *)object
                                part:(NSString *)part
                    uploadParameters:(GTLUploadParameters *)uploadParametersOrNil {

And the error check for a nil object is being passed, so the query is fine, its 
just not being executed. 

Original comment by michael....@trickbook.com on 20 Sep 2013 at 8:04

GoogleCodeExporter commented 9 years ago
In the Breakpoints pane of Xcode, click the + in the lower left to add an 
exception breakpoint.

Is anything showing up in the http log?  

https://code.google.com/p/gtm-http-fetcher/wiki/GTMHTTPFetcherIntroduction#HTTP_
Logging

Original comment by grobb...@google.com on 20 Sep 2013 at 8:17

GoogleCodeExporter commented 9 years ago
When i try to enable logging using [GTMHTTPFetcher setLoggingEnabled I get 
+[GTMHTTPFetcher setLoggingEnabled:]: unrecognized selector sent to class 
0x40e538. 
No exceptions in the code prior to this. 

Original comment by michael....@trickbook.com on 20 Sep 2013 at 9:09

GoogleCodeExporter commented 9 years ago
Is GTMHTTPFetcherLogging.h/m in the project target?

Original comment by grobb...@google.com on 20 Sep 2013 at 9:17

GoogleCodeExporter commented 9 years ago
Ugh.. turns out I didnt have GTMHTTPFetcherLogging.m/GTMHTTPUploadFetcher.m in 
my project target, thought i had these covered elsewhere. Thats so annoying. 
Thanks so much for your help, I've been stuck on this for far too long. 
Thankyou so much. 

Original comment by michael....@trickbook.com on 20 Sep 2013 at 9:33

GoogleCodeExporter commented 9 years ago
Hello,

I'm here to report that I also have the same issue. I have authentication set 
up, and I'm trying to the description associated with a YouTube video. It 
worked, and then one day it just stopped in August/early September. This 
functionality was not critical to the application and was dropped, believing it 
was an issue with Google's API, but now the feature does need to be implemented.

My problem is the same as the OP. There are no differences code-wise.

Here's the section of my code where I create the query:

dispatch_async(dispatch_get_main_queue(), ^(void) {
                [self setUpPlaybackOfAsset:asset withKeys:assetKeysToLoadAndTest];

                GTLQueryYouTube *query = [GTLQueryYouTube queryForVideosListWithPart:@"snippet"];
                [query setIdentifier:[HCYoutubeParser youtubeIDFromYoutubeURL:_videoURL]]; // Hard code for now.

                __block NSString *result = @"";
                GTLServiceYouTube *service = self.youTubeService;
                NSLog(@"Preparing to fetch video description. %@", service);
                if (service) {
                    [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
                        if (!error) {
                            GTLYouTubeVideoListResponse *response = (GTLYouTubeVideoListResponse *)object;
                            if (response[0]) {
                                GTLYouTubeVideo *video = response[0]; // Since we specified the ID of the video we want, there's only one entry in the array. Otherwise, we'd have to iterate through (i.e if we want to search).

                                NSLog(@"Got description: %@", result);
                                result = video.snippet.descriptionProperty;
                            [self.videoDescriptionTextField setString:result];
                            } else {
                                [self.videoDescriptionTextField setString:@"Failed to get video description."];
                            }
                        } else {
                            NSLog(@"An error occurred: %@", error);
                        }
                    }];
                } else {
                    NSLog(@"Can't get YouTube service object.");
                }
});

No log statements fire except for the initial one, where it says "Preparing to 
fetch video description".

Here's how the YouTube service object is constructed:

- (GTLServiceYouTube *)youTubeService {
    static GTLServiceYouTube *service;

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        service = [[GTLServiceYouTube alloc] init];

        // Have the service object set tickets to fetch consecutive pages
        // of the feed so we do not need to manually fetch them.
        service.shouldFetchNextPages = YES;

        // Have the service object set tickets to retry temporary error conditions
        // automatically.
        service.retryEnabled = YES;
    });
    return service;
}

I set breakpoints as you suggested in #4, and coupled a log statement to fire 
when an exception occurs. After the previously mentioned log statement, I get 
22 exceptions:

2013-10-26 13:15:04.742 Youtube App[46771:303] Preparing to fetch video 
description. <GTLServiceYouTube: 0x608000151460>
Exception:  hit at All Exceptions. This has occurred 11 times.
.....
Exception:  hit at All Exceptions. This has occurred 33 times.

Additionally, I set GTMHTTPFetcher to fire with the following code:

    [GTMHTTPFetcher setLoggingEnabled:YES];
    [GTMHTTPFetcher setLoggingToFileEnabled:YES];
    [GTMHTTPFetcher setLoggingDirectory:NSHomeDirectory()];

Because my application is designed for the Mac App Store, it is sandboxed, and 
the proper permissions are set to allow outgoing network access. This was set 
before the query stopped executing, so I'm guessing that this is not the case.

I'd love to know if you have any suggestions or advice. 

Original comment by sevenbit...@gmail.com on 26 Oct 2013 at 5:29