Как получить ID Youtube канала при авторизации через google oauth?
Всем привет.
Делаю следующее: отправляю запрос
$params = array(
'client_id' => Cms::setup('google_key'),
'redirect_uri' => Cms::setup('home') . '/' . Base::locale() . '/oauth/google',
'response_type' => 'code',
'access_type' => 'offline',
'prompt' => 'consent',
'flowName' => 'GeneralOAuthFlow',
'include_granted_scopes' => 'true',
'gsiwebsdk' => '2',
'openid.realm' => '',
'scope' => 'openid profile email https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/yt-analytics.readonly',
);
$url = 'https://accounts.google.com/o/oauth2/auth?' . urldecode(http_build_query($params));
https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?client_id=МОЙ_КЛИЕНТ_ИД&redirect_uri=СТРАНИЦА_РЕДИРЕКТА&response_type=code&access_type=offline&prompt=consent&flowName=GeneralOAuthFlow&include_granted_scopes=true&gsiwebsdk=2&openid.realm&scope=openid%20profile%20email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyt-analytics.readonly
На странице редиректа отправляю запрос сюда https://www.googleapis.com/oauth2/v1/userinfo?КОД и получаю данные пользователя. Но как вместо обычных данных пользователя получить данные его ютуб канала или хотя бы ID его канала?
$params = array(
'access_token' => $data['access_token'],
'id_token' => $data['id_token'],
'token_type' => 'Bearer',
'expires_in' => 3599,
'part' => 'statistics',
);
$info = file_get_contents('https://www.googleapis.com/oauth2/v3/userinfo?' . urldecode(http_build_query($params)));
$info = json_decode($info, true);
return $info;