title: Google Drive Api intergration with php
body: <p>I want to show my google drive into website.  Which means  if anybody use my website can see google drive files and folder without login.  Here is some code which i am trying to implement. </p>
  
  <pre><code>include_once 'google-api-php-client/src/Google/autoload.php';
      $scopes = array( 'https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.appdata',
      'https://www.googleapis.com/auth/drive.file','https://www.googleapis.com/auth/drive.metadata','https://www.googleapis.com/auth/drive.metadata.readonly','https://www.googleapis.com/auth/drive.photos.readonly','https://www.googleapis.com/auth/drive.readonly');
  
      /**
       * Create AssertionCredentails object for use with Google_Client
       */
      $creds = new Google_Auth_AssertionCredentials(
          $serviceAccountName,
          $scopes,
          file_get_contents($keyFile)
      );
  
      $creds-&gt;sub = $delegatedAdmin;
  
      /**
       * Create Google_Client for making API calls with
       */
      $client = new Google_Client();
      $client-&gt;setApplicationName($appName);
      $client-&gt;setClientId($clientId);
      $client-&gt;setAssertionCredentials($creds);
  
      /**
       * Get an instance of the Directory object for making Directory API related calls
       */
      $service = new Google_Service_Drive($client);
  
      $optParams = array(
        'pageSize' =&gt; 10,
        'fields' =&gt; "nextPageToken, files(id, name)"
      );
      $results = $service-&gt;files-&gt;listFiles($optParams);
      print_r($results); exit;
      /**
  </code></pre>
  
  <p>Can anybody tel me how to achieve this.  I am getting this error </p>
  
  <pre><code>Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "unauthorized_client", "error_description" : "Unauthorized client or scope in request." } 
  </code></pre>