2
votes

I'm using the YouTube API to retrieve a channel's sponsor list. It was working correctly a few days ago, but on 2019-12-13 started returning error 403:

Access forbidden. The request may not be properly authorized.

I can make the user log in and give permissions to the app. The error happens when I try to retrieve the sponsor list from the user's channel.

Excerpt from the code I am using:

$client = new Google_Client();
$client->setScopes('https://www.googleapis.com/auth/youtube.readonly');
$client->setClientId('CLIENT_ID');
$client->setClientSecret('CLIENT_SECRET');
$client->setAccessType('offline');
$client->setAccessToken([
    'access_token' => 'TOKEN',
    'refresh_token' => 'REFRESH_TOKEN',
    'expires_in' => 'EXPIRES_IN',
]);

$params = [
    'filter' => 'all',
    'maxResults' => 50
];

$service = new Google_Service_YouTube($client);
$response = $service->sponsors->listSponsors('snippet', $params);

How to fix this error? What do I need to change?

Additional Information:

  • I followed the documentation and, as I said, it was working;
  • The OAuth consent screen has the status "Published";
  • The YouTube Data API v3 are enabled;
  • I am using the scope https://www.googleapis.com/auth/youtube.readonly;
  • I am using a OAuth 2.0 credential;
  • I can access other services within the class "Google_Service_YouTube" less related to the sponsors;
  • For the purpose of testing, I created 2 other projects and generated the clients and the same error 403 was returned.

Thanks!

[EDIT]

I still couldn't solve the problem...

I did some tests with "OAuth 2.0 Playground" and when I use the default settings I get the sponsor list, but when I put the client ID of my project it gives error 403.

I have no idea why the request starts to return the error. There were no changes to the code or project settings.

1
I'm seeing the exact same issue. Did you find a solve?Barry Carlyon
@BarryCarlyon Not yet... A month ago I posted about it on IssueTracker and two people said they have the same problem as me. Unfortunately, that's all I got. :(Diego R. Lima

1 Answers

0
votes