title: How can I re-acquire a Shopify OAuth access token for a store that has previously installed my application?
body: <p>I requested authorization for a public application to be able to access store data via the Shopify API.</p>
  
  <p>The store successfully authorized my application via an authorization request URL such as </p>
  
  <pre><code>https://some-store.myshopify.com/admin/oauth/authorize?client_id=123abc&amp;scope=read_inventory%2Cread_products&amp;redirect_uri=http%3A%2F%mysite.com%2Fauth.php&amp;state=123456
  </code></pre>
  
  <p>and the response was passed back to my application. This response (containing the code that can be exchanged for a permanent access token) was mishandled by my application (an error on the page meant that the access token was not stored).</p>
  
  <p>Everything I read regarding requesting these tokens involves authorization by the store - but given the store has already authorized my application, passed back <strong>the code and that code has already successfully been exchanged for a token</strong>: is there a way my application can request that same token or a fresh one using my API keys given that the application is already authorized?</p>
  
  <p>The only method I currently can find for requesting a token requires starting back at the beginning and fetching a code for exchange etc.</p>
  
  <p>I working in PHP and using <a href="https://github.com/LukeTowers/php-shopify-api" rel="nofollow noreferrer">Luke Towers' php shopify wrapper</a> </p>
  
  <p>This stage was completed successfully:</p>
  
  <pre><code>    function check_authorization_attempt()
  {
      $data = $_GET;
  
      $api = new Shopify($data['shop'], [
          'api_key' =&gt; '123',
          'secret'  =&gt; '456',
      ]);
  
      $storedAttempt = null;
      $attempts = json_decode(file_get_contents('authattempts.json'));
      foreach ($attempts as $attempt) {
          if ($attempt-&gt;shop === $data['shop']) {
              $storedAttempt = $attempt;  
              break;
          }
      }
  
      return $api-&gt;authorizeApplication($storedAttempt-&gt;nonce, $data);
  }
  
  $response = check_authorization_attempt();
  </code></pre>
  
  <p>and I would have been able to read the access token from :</p>
  
  <pre><code> $access_token = $response-&gt;access_token;
  </code></pre>
  
  <p>But this was the stage at which my application hit an error in accessing a database in which to write said token.</p>
  
  <p>I cannot repeat it without repeating the auth request because the data in $_GET that's passed to this function comes from Shopify's response to the shop owner authorizing the access, and includes amoung other things the code for exchange.</p>