title: In Google API v2, why is the error "The project id used to call the Google Play Developer API has not been linked" happening?
body: <p>When I'm using Google API v2, to get an <a href="https://developers.google.com/android-publisher/api-ref/inappproducts/list" rel="nofollow noreferrer">inapp listing</a>, I'm getting the following error when I'm making the API call:</p>
  
  <pre><code>{
   "error": {
    "errors": [
     {
      "domain": "androidpublisher",
      "reason": "projectNotLinked",
      "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
     }
    ],
    "code": 403,
    "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
   }
  }
  </code></pre>
  
  <p>I then researched this error and ended up seeing the suggestions on <a href="https://stackoverflow.com/questions/25156536/androidpublisher-api-return-projectnotlinked-error">this</a> page, <a href="https://stackoverflow.com/questions/25054919/get-android-subscription-status-failed-with-403/">this</a> page, and on <a href="https://stackoverflow.com/questions/25481207/why-getting-error-the-project-id-used-to-call-the-google-play-developer-api-has">this</a> page as well. I followed and double-checked the way the projects get linked there but it did not help.</p>
  
  <p>This is what I did...</p>
  
  <p>In Google Developer Console:</p>
  
  <ol>
  <li>Used an existing project.</li>
  <li>Went to APIs &amp; auth > APIs.</li>
  <li>Ensured "Google Play Android Developer API" was turned ON.</li>
  <li>Used my existing credentials for CLIENT ID, CLIENT SECRET, and REDIRECT URIS. Application type was "native application".</li>
  <li>Created an API KEY as well, but did not use it.</li>
  </ol>
  
  <p>In Google Play Developer Console:</p>
  
  <ol>
  <li>Went to SETTINGS > API access.</li>
  <li>Under LINKED PROJECT, I ensured the above project from the Google Developer Console was linked.</li>
  </ol>
  
  <p>In my PHP script:</p>
  
  <pre><code>&lt;?php
  
  require_once('/var/www/html/common/include.php');
  require_once realpath(dirname(__FILE__) . '/lib/Google/autoload.php');
  
  $refreshToken = '1/sometoken';
  $packageName = 'com.somepackage';
  
  $client_id = GOOGLE_CLIENT_ID;
  $client_secret = GOOGLE_CLIENT_SECRET;
  $redirect_uri = 'http://localhost';
  
  $client = new Google_Client();
  $client-&gt;setClientId($client_id);
  $client-&gt;setClientSecret($client_secret);
  $client-&gt;setRedirectUri($redirect_uri);
  $client-&gt;setAccessType('offline');
  $client-&gt;setApprovalPrompt('force');
  $client-&gt;setScopes(['https://www.googleapis.com/auth/androidpublisher']);
  $client-&gt;refreshToken($refreshToken);
  
  $service = new Google_Service_AndroidPublisher($client);
  $response = $service-&gt;inappproducts-&gt;listInappproducts($packageName);
  
  var_dump($service);
  </code></pre>
  
  <p>Which led to the above error. </p>
  
  <p>Any other suggestions to resolve this error with using refresh tokens? </p>