title: OAuth2 - Error 400: redirect_uri_mismatch
body: <p>I own a site and would like to place my products on Google Shopping, I currently use Google spreadsheets, but I would like to do this through integration. To import my products automatically. For this I verified that I need to use OAuth, but I am not able to make it work. I can not find where the error might be.</p>
  
  <p>Code PHP:</p>
  
  <pre><code>&lt;?php
  require_once __DIR__ . '/vendor/autoload.php';
  
  define('MERCHANT_ID', 'xxxxxxxxx');
  session_start();
  
  try {
       $client = new Google_Client();
       $client-&gt;setAuthConfig(__DIR__ . '/Merchant_Center-c8fd21e1ec51.json'); 
       $client-&gt;addScope(Google_Service_ShoppingContent::CONTENT);
  } catch (Google_Exception $e) {
      echo 'Error.';
  }
  
  $request_uri = 'https://mywebsite.com/googleShopping/';
  $client-&gt;setRedirectUri($request_uri);
  
  if (isset($_SESSION['oauth_access_token'])) {
      $client-&gt;setAccessToken($_SESSION['oauth_access_token']);
  
      if ($client-&gt;isAccessTokenExpired()) {
          unset($_SESSION['oauth_access_token']);
      }
  } elseif (isset($_GET['code'])) {
      $client-&gt;authenticate($_GET['code']);
      $token = $client-&gt;fetchAccessTokenWithAuthCode($_GET['code']);
      $_SESSION['oauth_access_token'] = $token;
  } else {
      $auth_url = $client-&gt;createAuthUrl();
      header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
      exit;
  }
  
  $service = new Google_Service_ShoppingContent($client);
  print_r($service-&gt;products-&gt;get(MERCHANT_ID, 'online:en:US:10081'));
  </code></pre>
  
  <p>Merchant_Center-c8fd21e1ec51.json file:</p>
  
  <p><a href="https://i.stack.imgur.com/cB61u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cB61u.png" alt="Merchant_Center-c8fd21e1ec51.json file"></a></p>
  
  <p>The error:</p>
  
  <p><a href="https://i.stack.imgur.com/3fNMS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3fNMS.png" alt="The error"></a></p>
  
  <p>Credentials:</p>
  
  <p><a href="https://i.stack.imgur.com/OyekY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OyekY.png" alt="Credentials"></a></p>
  
  <p>OAuth consent screen:</p>
  
  <p><a href="https://i.stack.imgur.com/T1Mdn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T1Mdn.png" alt="OAuth consent screen"></a></p>
  
  <p>Domain Verification:</p>
  
  <p><a href="https://i.stack.imgur.com/nTNOx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nTNOx.png" alt="Domain Verification"></a></p>
  
  <p>Service accounts:</p>
  
  <p><a href="https://i.stack.imgur.com/1nyTt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1nyTt.png" alt="Service accounts"></a></p>
  
  <p>Could someone tell me what could be happening? Thanks a lot.</p>