title: How to programmatically get the access token to send API call to Google Merchant Center (Google Shopping) with PHP?
body: <p>I recently get in touch with Google merchant product to sync all my website products into Google Merchant. When I follow the structure of the API documentation <a href="https://developers.google.com/shopping-content/v2/quickstart" rel="nofollow noreferrer">https://developers.google.com/shopping-content/v2/quickstart</a>
  down to Authorization section I copy their library and copy the sample code to use. It actually work! However, when I doing testing to load that auth page it requires me to log in to the developer account for getting the access token and save it into session.</p>
  <p>Is there any possibility that I can skip the login section to make it automatically then I can do corn system to run the sync (update products' details) hourly?</p>
  <p>I tried to hardcore my account login API key into my code like this:</p>
  <pre><code>$client = new Google_Client();
  $client-&gt;setApplicationName('Sample Content API application');
  
  //add my api key here
  $client-&gt;setDeveloperKey(MY_API_KEY);
  
  $client-&gt;setClientId('YOUR_CLIENT_ID');
  $client-&gt;setClientSecret('YOUR_CLIENT_SECRET');
  $client-&gt;setRedirectUri('YOUR_REDIRECT_URI');
  $client-&gt;setScopes('https://www.googleapis.com/auth/content');
  </code></pre>
  <p>But it doesn't workЖ шt still requires me to log in.</p>