Question

I'm trying to use the YouTube v3 API to perform searches using the APIKey instead of the oAuth2.

My problem is that when I use APIKey, the queries always return an error.

This is the code for initializing the service

_service = [[GTLServiceYouTube alloc] init];
[_service setRetryEnabled:YES];
[_service setAPIKey:kAPIKey];

and this the code for the query

GTLQueryYouTube *query = [GTLQueryYouTube queryForSearchListWithPart:@"snippet"];
query.q = filter;
query.type = type;
query.maxResults = maxResults;

[_service executeQuery:query completionHandler:
 ^(GTLServiceTicket *ticket, GTLYouTubeSearchListResponse *searchListResponse, NSError *error)
{
//-- do stuff
 }];

The error it returns when using APIKey is the following. if I use oAuth everything goes as expected.

error: Error Domain=com.google.GTLJSONRPCErrorDomain Code=403 "The operation couldn’t be completed. (Access Not Configured)" UserInfo=0x13d10ac0 {error=Access Not Configured, GTLStructuredError=GTLErrorObject 0x13d0c770: {message:"Access Not Configured" code:403 data:[1]}, NSLocalizedFailureReason=(Access Not Configured)}

I have created the APIKey on the Google APIs Console and the service is enabled.

Was it helpful?

Solution

not the ideal solution... but I found a workaround in this post: google-youtube-api-v3-ios-app-key-403-error-code

basically, it will work if we use a "Key for browser apps" instead of a "Key for iOS apps".

OTHER TIPS

Have you switch on youtube api from service panel in google-console?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top