I am trying to create a service-side PHP application that simply returns a list of my Youtube channel members. The documentation does not give a clear example on how to use this scope specifically and neither API key or OAuth credentials have worked so far. If I use API key I get an error saying "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal". So on getting this error I tried with OAuth client credentials, but the information I can find in the documentation suggests that I need the user to login via the browser to get the access token and then fetch the information, which will not work since this is a server-side standalone application.
I read that the Youtube API does not support service accounts but in a last ditch effort I tried with that as well, which gave me an error saying "Access forbidden. The request may not be properly authorized. Domain:youtube.common".
My goal is to create a simple page that only my Youtube members can access. I've looked into doing this from the other direction by fetching the users membership information as they login, but I cannot find any information whatsoever about that in the documentation so I have put that on ice for now (but if anyone have any information on that I would gladly go down that rabbit hole instead).
If anyone can shine some light on this I would greatly appreciate it.
What I tried
$client = new Google_Client(); $client->setApplicationName("Test"); $client->setScopes(["https://www.googleapis.com/auth/youtube.channel-memberships.creator" ]); $client->setAuthConfig(base_path() . '/' . env('SECRETS_FILE')); $service = new Google_Service_YouTube($client); $response = $service->members->listMembers('snippet'); print_r($response);What I expected
A list of member objects from my own Youtube channel