Firstly, this question may sound like a duplicate but from the answers I've already seen I think the answers don't correctly fit this purpose because I do not have permission.
I'm trying to find a YouTube channel ID after they authorize their Google account.
The scopes I am using are:
https://www.googleapis.com/auth/yt-analytics.readonly
https://www.googleapis.com/auth/userinfo.profile
A lot of the answers refer to accessing the V3 channels api to get the channel id.
$channelData = file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token=".$token['access']);
$channelData = json_decode($channelData, true);
The issue is with the scopes I'm using you cannot access this. The other questions on SO all revolve around this endpoint.
Youtube API Retrieving Channel ID after authentication
How to get Channel ID (YouTube API v2)?
How to Get Channel id or url after Google Oauth PHP
Please note I want to keep scopes to an absolute minimum. Why wouldn't this simply be possible with just the analytics API? Will I have to use another YouTube scope to find the channel id of the person who just authorised?
The question I'm asking is
Is there any way I can get the channel id of the user who just authorised with my current scopes? If not what is the minimum-amount-of-permission-scopes I can use to get their channel id?
Get the YouTube channel ID To obtain the channel id you can view the source code of channel page and find there data-channel-external-id="XXXXXXXXXXXXXXXXXXXXXXXX" this will be the channel id you are looking for!
You should add youtube.readonly
scope, plugins like socialite
have exactly this scope hardcoded. The channel snippet
can be got via channels
method - docs with part=snippet
.
Readonly scope is light enough to include it to your list. userinfo.profile
and yt-analytics.readonly
don't have access to channels list. This scope is the only one needed to get channel id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With