title: Does Bigquery instance in java api refresh it's Oauth 2.0 authorization automatically after building it with a credential that has a refresh token?
body: <p>Good day,</p>
  
  <p>I was recently testing Oauth2.0 Installed application authentication for bigquery through java api.
  I used 
  <a href="http://code.google.com/p/google-api-java-client/source/browse/shared/shared-sample-cmdline/src/main/java/com/google/api/services/samples/?repo=samples#samples%2Fshared%2Fcmdline%2Foauth2" rel="nofollow">this command line sample</a>
   as a source since i want to make it for the users eaiser to give access (it would be ugly to ask them to copy the code)</p>
  
  <p>If i use SetAccessType(Offline) in GoogleAuthorizationCodeflow it says, that it automatically refreshes the access token for me. </p>
  
  <p>In related I'd like to ask, if i authorize a com.google.api.services.bigquery.Bigquery instance with 
  com.google.api.services.bigquery.Bigquery.Builder.Builder(HttpTransport transport, JsonFactory jsonFactory, HttpRequestInitializer httpRequestInitializer)
  using
  credentials that have a refresh token, do i have to reauthorize it or it will update the credentials inside itself? </p>
  
  <p>If it does not give me a valid connection to bigquery after one hour (token expiration time)
  then which is the best method to reauthorize the client?</p>
  
  <p>Shall i use credentials.RefreshToken() and then just Build another bigquery instance whith the new access token, or there is a better way?</p>
  
  <p>(I may also want to change the credentials Refreshlistener, but the problem is that if i instantinate the credential with GoogleAuthorizationCodeflow.createAndStoreCredential(response, Clientid) after that i cannot get the Refreshlistener. How can i get it, so i may use that class to automatically reauthorize my Bigquery Client  &lt; maybe this is the better way is it?)</p>
  
  <p>Where does the codeflow store the refreshed access token (if it refreshes it automatically)?
  If i declared it like this:</p>
  
  <pre><code>new GoogleAuthorizationCodeFlow.Builder(
                transport, jsonFactory, clientSecrets, scopes).setAccessType("offline")
                .setApprovalPrompt("auto").setCredentialStore(new MemoryCredentialStore()).build();
  </code></pre>
  
  <p>Will it store my refreshed access token always in the MemoryCredentialStore? 
  So if i use .getCredentialStore().load(userId, credential) it will load the refreshed access token from the memorystore?</p>
  
  <p>Is there a way to increase or decrease the time while an access token is valid? Since for testing purposes i really want to do so.</p>
  
  <p>p.s: I was also looking into this source code of google-api-java-client
  and google-oauth-java-client but i still couldn't find the sollution.</p>
  
  <p>Most importantly I was looking into: <a href="http://code.google.com/p/google-oauth-java-client/source/browse/google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/Credential.java?r=3797dd06637996cb2bd231dd9c19925d80295de3" rel="nofollow">class Credential</a> at code: 
  public void intercept(HttpRequest request) throws IOException {
      lock.lock();...
  but I couldnt figure it out actually when this method is called and I eventually got lost in the problem.</p>
  
  <p>Looking forward to your answer:
  Attila</p>