pod 'GoogleAPIClientForREST/YouTube'
pod 'GoogleAPIClientForREST/Oauth2'
pod "youtube-ios-player-helper"
For example I try get list of my videos:
self.service = [GTLRYouTubeService new];
self.service.APIKey = @"API_KEY";
GTLRYouTubeQuery_ActivitiesList *query = [GTLRYouTubeQuery_ActivitiesList queryWithPart:@"contentDetails"];
query.mine = YES;
[self.service executeQuery:query completionHandler:^(GTLRServiceTicket *ticket, id object, NSError *error) {
NSLog(@"object is %@",object);
NSLog(@"error is %@",error);
}];
and upload video:
self.service = [GTLRYouTubeService new];
self.service.APIKey = @"API_KEY";
GTLRYouTube_Activity *activObjec = [GTLRYouTube_Activity new];
GTLRYouTubeQuery_ActivitiesInsert *query = [GTLRYouTubeQuery_ActivitiesInsert queryWithObject:activObjec part:@"fileDetails"];
[self.service executeQuery:query completionHandler:^(GTLRServiceTicket *ticket, id object, NSError *error) {
NSLog(@"object is %@",object);
NSLog(@"error is %@",error);
}];
And I get 401 error "Login Required" for upload video and 401 error "The request uses the mine parameter but is not properly authorized.".
Wherein I generate in google developer console API key for iOS (without bundle id) and OAuth 2.0 identifier:
and I add to info.plist file:
<key>CLIENT_ID</key>
<string>client id from google console</string>
<key>REVERSED_CLIENT_ID</key>
<string>reversed client id from google console</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.ncl.VideoImploder</string>
But I dont understand, that goes wrong. What I doing incorrect?
I see method:
- (void)setAuthorizer:(id <GTMFetcherAuthorizationProtocol>)authorize;
in GTLRYouTubeService, but I dont understand send client_id and api_key to it method, I dont see similar properties in GTMFetcherAuthorizationProtocol protocol.
And I dont understand how I can attach video file to GTLRYouTubeQuery_ActivitiesInsert.
Please, say me, how setup authorization and upload file in GoogleAPIClientForREST?