title: Authenticate Javascript Program for Gcloud AutoML Vision API
body: <p>I am currently working on a project whereby I have used gcloud automl to train an image classifier. I have got it working fine and it is able to handle my requests using access-tokens. However, my issue lies in that access-tokens only last for an hour. I would like to be able to create a method in my client-side javascript or another way to authenticate such that it is indefinite and I do not need to manually generate new tokens.</p>
  
  <p>I have looked through the samples and docs on gcloud and found a sample that describes a possibility with the People API but I am not sure how to translate this to the Vision API.</p>
  
  <p>Currently I am sending a request like the following:</p>
  
  <pre><code>$.ajax({
          url: "https://automl.googleapis.com/v1beta1/projects/(project-id)/locations/us-central1/models/(model-id):predict",
          beforeSend: function(xhr) { 
              xhr.setRequestHeader("Authorization", "Bearer " + "access-token"); 
          },
          type: 'POST',
          dataType: 'json',
          contentType: 'application/json',
          processData: false,
          data: objString,
          success: function (data) {
              alert(JSON.stringify(data));
          },
          error: function(){
              alert("Cannot get data");
          }
      });
  </code></pre>
  
  <p>If there is a way to alter this method (or write a new one) to make a permanent token or another authentication form that is indefinite, then that would be much appreciated.</p>