title: OAuthTokenCredential Inactivity
body: <p>I developed a web platform that allows our customers (More than one), to receive payments, using PayPal REST API.</p>
  
  <p>Under development everything runs well, but in production, after some time of inactivity, looks like the required Authentication Token needs to be regenerated.</p>
  
  <p>To handle multiple customers I'm using a synchronized HashMap when the key is a composition between the customer_id and the payment_method_id and the value is a POJO, containing the token and a creation date.</p>
  
  <p>The token is the current OAuthTokenCredential, generated by the following code:</p>
  
  <pre><code>Properties p = new Properties();
  
  // Evaluate the right endpoint
  if (STATUS_ACTIVE) {
      p.put("service.EndPoint", "https://api.paypal.com");
  }
  else {
      p.put("service.EndPoint", "https://api.sandbox.paypal.com");
  }
  
  p.put("clientID", clientId);
  p.put("clientSecret", clientSecret);
  p.put("http.ConnectionTimeOut", "5000");
  p.put("http.Retry", "1");
  p.put("http.ReadTimeOut", "30000");
  p.put("http.MaxConnection", "100");
  p.put("http.UseProxy", "false");
  
  Payment.initConfig(p);
  
  OAuthTokenCredential tokenGen = new OAuthTokenCredential(
      clientId,
      clientSecret
  );
  </code></pre>
  
  <p><strong>The issue is that the user cannot buy, so it is a bug that I need to solve fast.</strong> </p>
  
  <p>The message I receive from paypal is the following:</p>
  
  <pre><code>Error Code 401 with response : Server returned HTTP response code 401 for url https://api.paypal.com/v1/payments/payment
  </code></pre>
  
  <p>Do you know if there are some timeouts on the OAuthTokenCredential Validity?
  I tested the code using junit, so, the token is generated and cached rightly.</p>
  
  <p>Now I have a 5' (300 Seconds) token timeout. Is there a best practice on doing this things? Is there something I wrong?</p>
  
  <p>Thanks a lot, Davide.</p>