I dont understand how I can authorize and upload video to YouTube in iOS

473 views
Skip to first unread message

Стас Тельнов

unread,
Jul 22, 2016, 8:35:29 AM7/22/16
to Google APIs Client Library for Objective-C
Hello.
I install next pods:
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?



Vishwa Infinite

unread,
Dec 8, 2016, 1:15:33 PM12/8/16
to Google APIs Client Library for Objective-C
Hello Стас Тельнов,

Am also facing similar issue, where you able to resolve it?
If yes can you let me know what changes you made to fix it.

Thanks

Abdul Rauf

unread,
Feb 28, 2017, 6:42:18 AM2/28/17
to Google APIs Client Library for Objective-C
Hi,
I have same task of upload video on youtube, library I was using depreciated.
if your task was done, kindly guide me how you did it, If feasible please share the code.
Reply all
Reply to author
Forward
0 new messages