Search code examples
iosyoutube-apigoogle-api-objc-client

Retrieving a youtube playlist without asking the user for login


is it possible to retrieve a public youtube playlist with the google-api-objectivec-client without asking the user to login in order to perform the OAuth 2.0 authentication?

I'm working on an app which should retrieve a playlist from youtube and play related videos, but I cannot and don't want to ask the user to login.

In the examples of google-api-objectivec-client (https://code.google.com/p/google-api-objectivec-client/source/browse/#svn%2Ftrunk%2FExamples%2FYouTubeSample) I'm not able to achieve it without OAuth 2.0 authentication.

Thanks, DAN


Solution

  • Yes, you don't need OAuth2 login for that. You can simply do it by setting your API key instead.

    It's a playlistItems->list request.

    Here's demonstration in api explorer: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.playlistItems.list?part=snippet&playlistId=PLjFEz-E0UPUxw3lFpnfV1dDA7OE7YIFRj&_h=2&

    Instead of setting the authorizer of the service to OAuth2 login like in

    youtubeservice.authorizer = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychain.....

    set it's API key to your API key from cloud console in Public API access.

    youtubeService.APIKey = xxxxxx