The request uses the <code>mine</code> parameter but is not properly authorized

Viewed 579

I'm trying to make this call to YouTube channels API with mine parameter but i got below error.

[
  "error" => array:3 [
    "errors" => array:1 [
      0 => array:5 [
        "domain" => "youtube.parameter"
        "reason" => "authorizationRequired"
        "message" => "The request uses the <code>mine</code> parameter but is not properly authorized."
        "locationType" => "parameter"
        "location" => "mine"
      ]
    ]
    "code" => 401
    "message" => "The request uses the <code>mine</code> parameter but is not properly authorized."
  ]
]

By the below code i am calling youtube v3 APIs

$client = new \Google_Client();
    $client->setAuthConfig(app_path('google-api.json'));

    $client->setScopes([
        'https://www.googleapis.com/auth/youtube',
        'https://www.googleapis.com/auth/youtubepartner-channel-audit',
        \Google_Service_YouTube::YOUTUBE_FORCE_SSL,
    ]);
    $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/login');
    $client->setAccessType('offline');       
    $client->setIncludeGrantedScopes(true);

    $httpClient = $client->authorize();

    $customerResponse = $httpClient->get('https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&mine=true&key={API_KEY}');

    $customer = json_decode($customerResponse->getBody()->getContents(), true);
1 Answers
Related