title: The service is currently unavailable Google api
body: <p>I'm using google slide API to connect to my project account, the connection worked perfectly, but sometime I get this error :</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Google_Service_Exception: { "error": { "code": 503, "message": "The service is currently unavailable.", "errors": [ { "message": "The service is currently unavailable.", "domain": "global", "reason": "backendError" } ], "status": "UNAVAILABLE" } } in /vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /vendor/google/apiclient/src/Google/Task/Runner.php(181): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run in /vendor/google/apiclient/src/Google/Http/REST.php on line 118</p>
  </blockquote>
  
  <p>This is my getClient function Google API:</p>
  
  <pre><code>function getClient(string $SCOPES,string $CLIENT_SECRET_PATH,string $CREDENTIALS_PATH,string $APPLICATION_NAME) {
  
      $this-&gt;client-&gt;setApplicationName($APPLICATION_NAME);
      $this-&gt;client-&gt;setScopes($SCOPES);
      $this-&gt;client-&gt;setAuthConfig($CLIENT_SECRET_PATH);
      $this-&gt;client-&gt;setAccessType('offline');
      $this-&gt;client-&gt;setApprovalPrompt('force');
  
      $credentialsPath = $this-&gt;expandHomeDirectory($CREDENTIALS_PATH);
      if (file_exists($credentialsPath)) {
          $accessToken = json_decode(file_get_contents($credentialsPath), true);
      } else {
  
          $authUrl = $this-&gt;client-&gt;createAuthUrl();
          printf("Open the following link in your browser:\n%s\n", $authUrl);
          print 'Enter verification code: ';
          $authCode = trim(fgets(STDIN));
  
          $accessToken = $this-&gt;client-&gt;fetchAccessTokenWithAuthCode($authCode);
  
          if(!file_exists(dirname($credentialsPath))) {
              mkdir(dirname($credentialsPath), 0700, true);
          }
          file_put_contents($credentialsPath, json_encode($accessToken));
          printf("Credentials saved to %s\n", $credentialsPath);
      }
      $this-&gt;client-&gt;setAccessToken($accessToken);
  
      if ($this-&gt;client-&gt;isAccessTokenExpired()) {
          $this-&gt;client-&gt;fetchAccessTokenWithRefreshToken($this-&gt;client-&gt;getRefreshToken());
          file_put_contents($credentialsPath, json_encode($this-&gt;client-&gt;getAccessToken()));
      }
      return $this-&gt;client;
  }
  </code></pre>
  
  <p>This is the request the I send:</p>
  
  <pre><code>public function replaceAllShapesWithImage(array $data_images)
  {
      $requests =array();
      if(isset($data_images)){
          foreach ($data_images as $key =&gt; $value) {
              $requests[] = new \Google_Service_Slides_Request(array(
                  'replaceAllShapesWithImage' =&gt; array(
                      'imageUrl' =&gt; $value['url'],
                      'replaceMethod' =&gt; $value['replaceMethod'],
                      'containsText' =&gt; array(
                          'text' =&gt; $value['text']
                      )
                  )
              ));
          }
      }
      return $requests;
  }
  </code></pre>
  
  <p><code>$data_image</code> has this value:</p>
  
  <pre><code>'replaceAllShapesWithImage' =&gt; array(
              0 =&gt; array(
                  'text'=&gt;'{{LOGO}}',
                  'url'=&gt;'http://www.16cafe.com/wp-content/themes/16cafe/css/images/logo.png',
                  'replaceMethod'=&gt;'CENTER_INSIDE'
              ),
              1 =&gt; array(
                  'text'=&gt;'{{PHOTO}}',
                  'url'=&gt;'http://localhost:9880/wp-content/uploads/2017/02/pla23.jpg',
                  'replaceMethod'=&gt;'CENTER_INSIDE'
              ),
          )
  </code></pre>