title: Google OAuth 2.0 PHP API Authentication fails: "Use of undefined constant STDIN"
body: <p>I am trying to implement the <code>PlaylistItems: insert</code> <a href="https://developers.google.com/youtube/v3/docs/playlistItems/insert" rel="nofollow noreferrer">YouTube Data API sample</a>, and when I try to run it, I get the following:</p>
  
  <p><strong>Notice</strong>: Use of undefined constant STDIN - assumed 'STDIN' in <strong>/example/path/to/script.php</strong> on line <strong>51</strong></p>
  
  <p>The function containing this line does not make it clear where STDIN gets it's value:</p>
  
  <pre><code>function getClient() {
    $client = new Google_Client();
    $client-&gt;setApplicationName('API Samples');
    $client-&gt;setScopes('https://www.googleapis.com/auth/youtube.force-ssl');
    // Set to name/location of your client_secrets.json file.
    $client-&gt;setAuthConfig('client_secrets.json');
    $client-&gt;setAccessType('offline');
  
    // Load previously authorized credentials from a file.
    $credentialsPath = expandHomeDirectory(CREDENTIALS_PATH);
    if (file_exists($credentialsPath)) {
      $accessToken = json_decode(file_get_contents($credentialsPath), true);
    } else {
      // Request authorization from the user.
      $authUrl = $client-&gt;createAuthUrl();
      printf("Open the following link in your browser:\n%s\n", $authUrl);
      print 'Enter verification code: ';
      $authCode = trim(fgets(STDIN)); // &lt;--- Appears to be the problem
  
      // Exchange authorization code for an access token.
      $accessToken = $client-&gt;fetchAccessTokenWithAuthCode($authCode);
  
      // Store the credentials to disk.
      if(!file_exists(dirname($credentialsPath))) {
        mkdir(dirname($credentialsPath), 0700, true);
      }
      file_put_contents($credentialsPath, json_encode($accessToken));
      printf("Credentials saved to %s\n", $credentialsPath);
    }
    $client-&gt;setAccessToken($accessToken);
  
    // Refresh the token if it's expired.
    if ($client-&gt;isAccessTokenExpired()) {
      $client-&gt;fetchAccessTokenWithRefreshToken($client-&gt;getRefreshToken());
      file_put_contents($credentialsPath, json_encode($client-&gt;getAccessToken()));
    }
    return $client;
  }
  </code></pre>
  
  <p>Please forgive my naiveté, but how is the script supposed to supply an auth code? Why is this step not performed?</p>